Freigeben über


PortTypeCollection.Insert(Int32, PortType) Methode

Definition

Fügt der PortType die angegebene PortTypeCollection am angegebenen nullbasierten Index hinzu.

public:
 void Insert(int index, System::Web::Services::Description::PortType ^ portType);
public void Insert (int index, System.Web.Services.Description.PortType portType);
member this.Insert : int * System.Web.Services.Description.PortType -> unit
Public Sub Insert (index As Integer, portType As PortType)

Parameter

index
Int32

Der nullbasierte Index, an dem der portType-Parameter eingefügt werden soll.

portType
PortType

Der der Auflistung hinzuzufügende PortType.

Ausnahmen

Der index-Parameter ist kleiner als 0 (null).

- oder - Der index-Parameter ist größer als Count.

Beispiele

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 );
ServiceDescription myServiceDescription =
   ServiceDescription.Read("MathService_CS.wsdl");

PortTypeCollection myPortTypeCollection =
   myServiceDescription.PortTypes;
int noOfPortTypes = myServiceDescription.PortTypes.Count;
Console.WriteLine("\nTotal number of PortTypes: " + noOfPortTypes);

PortType myNewPortType = myPortTypeCollection["MathServiceSoap"];

// Get the index in the collection.
int index = myPortTypeCollection.IndexOf(myNewPortType);
Console.WriteLine("Removing the PortType named "
   + myNewPortType.Name);

// Remove the PortType from the collection.
myPortTypeCollection.Remove(myNewPortType);
noOfPortTypes = myServiceDescription.PortTypes.Count;
Console.WriteLine("\nTotal number of PortTypes: "
   + noOfPortTypes);

// Check whether the PortType exists in the collection.
bool bContains = myPortTypeCollection.Contains(myNewPortType);
Console.WriteLine("Port Type'" + myNewPortType.Name + "' exists: "
   + bContains );

Console.WriteLine("Adding the PortType");
// Insert a new portType at the index location.
myPortTypeCollection.Insert(index, myNewPortType);
Dim myServiceDescription As ServiceDescription = _
   ServiceDescription.Read("MathService_VB.wsdl")

Dim myPortTypeCollection As PortTypeCollection = _
   myServiceDescription.PortTypes
Dim noOfPortTypes As Integer = myServiceDescription.PortTypes.Count
Console.WriteLine(ControlChars.Newline & _
   "Total number of PortTypes: " & noOfPortTypes.ToString())

Dim myNewPortType As PortType = myPortTypeCollection("MathServiceSoap")
' Get the index in the collection.
Dim index As Integer = myPortTypeCollection.IndexOf(myNewPortType)
Console.WriteLine("Removing the PortType named " & _
   myNewPortType.Name)

' Remove the PortType from the collection.
myPortTypeCollection.Remove(myNewPortType)
noOfPortTypes = myServiceDescription.PortTypes.Count
Console.WriteLine(ControlChars.Newline & _
   "Total number of PortTypes: " & noOfPortTypes.ToString())

' Check whether the PortType exists in the collection.
Dim bContains As Boolean = myPortTypeCollection.Contains(myNewPortType)
Console.WriteLine("Port Type'" & myNewPortType.Name & _
   "' exists: " & bContains.ToString())

Console.WriteLine("Adding the 'PortType'")
' Insert a new portType at the index location.
myPortTypeCollection.Insert(index, myNewPortType)

Hinweise

Wenn die Anzahl der Elemente in der Auflistung bereits die Kapazität der Auflistung entspricht, wird die Kapazität durch automatische Neuverlagerung des internen Arrays verdoppelt, bevor das neue Element eingefügt wird.

Wenn der Wert des index Parameters gleich Countist, wird die angegebene PortType Instanz am Ende des PortTypeCollectionWerts hinzugefügt.

Die Elemente nach der Einfügemarke werden nach unten verschoben, um das neue Element zu erfüllen.

Gilt für