PortTypeCollection::Insert Method (Int32, PortType^)
.NET Framework (current version)
Adds the specified PortType to the PortTypeCollection at the specified zero-based index.
Assembly: System.Web.Services (in System.Web.Services.dll)
Parameters
- index
-
Type:
System::Int32
The zero-based index at which to insert the portType parameter.
- portType
-
Type:
System.Web.Services.Description::PortType^
The PortType to add to the collection.
| Exception | Condition |
|---|---|
| IndexOutOfRangeException |
If the number of items in the collection already equals the collection's capacity, the capacity is doubled by automatically reallocating the internal array before the new element is inserted.
If the value of the index parameter is equal to Count, the specified PortType instance is added to the end of the PortTypeCollection.
The elements after the insertion point move down to accommodate the new element.
ServiceDescription^ myServiceDescription = ServiceDescription::Read( "MathService_CS.wsdl" ); PortTypeCollection^ myPortTypeCollection = myServiceDescription->PortTypes; int noOfPortTypes = myServiceDescription->PortTypes->Count; Console::WriteLine( "\nTotal number of PortTypes: {0}", noOfPortTypes ); PortType^ myNewPortType = myPortTypeCollection[ "MathServiceSoap" ]; // Get the index in the collection. int index = myPortTypeCollection->IndexOf( myNewPortType ); Console::WriteLine( "Removing the PortType named {0}", myNewPortType->Name ); // Remove the PortType from the collection. myPortTypeCollection->Remove( myNewPortType ); noOfPortTypes = myServiceDescription->PortTypes->Count; Console::WriteLine( "\nTotal number of PortTypes: {0}", noOfPortTypes ); // Check whether the PortType exists in the collection. bool bContains = myPortTypeCollection->Contains( myNewPortType ); Console::WriteLine( "Port Type'{0}' exists: {1}", myNewPortType->Name, bContains ); Console::WriteLine( "Adding the PortType" ); // Insert a new portType at the index location. myPortTypeCollection->Insert( index, myNewPortType );
.NET Framework
Available since 1.1
Available since 1.1
Show: