OperationCollection.Insert(Int32, Operation) 方法

定义

将指定的 Operation 添加到 OperationCollection 中指定的从零开始的索引处。

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

参数

index
Int32

将在该处插入 operation 参数的从零开始的索引。

operation
Operation

要添加到集合中的 Operation

示例

下面的示例演示 Insert 方法的用法。

myOperationCollection->Remove( myOperation );

// Insert the 'myOpearation' operation at the index '0'.
myOperationCollection->Insert( 0, myOperation );
Console::WriteLine( "The operation at index '0' is : {0}", myOperationCollection[ 0 ]->Name );
myOperationCollection.Remove(myOperation);
// Insert the 'myOpearation' operation at the index '0'.
myOperationCollection.Insert(0, myOperation);
Console.WriteLine("The operation at index '0' is : " +
                  myOperationCollection[0].Name);
myOperationCollection.Remove(myOperation)
' Insert the 'myOpearation' operation at the index '0'.
myOperationCollection.Insert(0, myOperation)
Console.WriteLine("The operation at index '0' is : " + _
                  myOperationCollection.Item(0).Name)

注解

如果集合中的项数已等于集合的容量,则插入新元素之前自动重新分配内部数组来增加容量。

index如果参数等于Count,则参数operation将添加到末尾OperationCollection

插入点下移以容纳新元素的元素。

适用于