OperationBindingCollection.Insert(Int32, OperationBinding) 方法

定义

将指定的 OperationBinding 实例添加到 OperationBindingCollection 中指定的从零开始的索引处。

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

参数

index
Int32

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

bindingOperation
OperationBinding

要添加到集合中的 OperationBinding

示例

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

// Insert the OperationBinding of the Add operation at index 0.
myOperationBindingCollection->Insert( 0, addOperationBinding );
Console::WriteLine( "\nInserted the OperationBinding of the "
"Add operation in the collection." );

// Get the index of the OperationBinding of the Add
// operation from the collection.
int index = myOperationBindingCollection->IndexOf( addOperationBinding );
Console::WriteLine( "\nThe index of the OperationBinding of the Add operation : {0}", index );
// Insert the OperationBinding of the Add operation at index 0.
myOperationBindingCollection.Insert(0, addOperationBinding);
Console.WriteLine("\nInserted the OperationBinding of the " +
   "Add operation in the collection.");

// Get the index of the OperationBinding of the Add
// operation from the collection.
int index = myOperationBindingCollection.IndexOf(addOperationBinding);
Console.WriteLine("\nThe index of the OperationBinding of the " +
   "Add operation : " + index);
' Insert the OperationBinding of the Add operation at index 0.
myOperationBindingCollection.Insert(0, addOperationBinding)
Console.WriteLine(ControlChars.NewLine & _
   "Inserted the OperationBinding of the " & _
   "Add operation in the collection.")

' Get the index of the OperationBinding of the Add
' operation from the collection.
Dim index As Integer = myOperationBindingCollection.IndexOf( _
   addOperationBinding)
Console.WriteLine(ControlChars.NewLine & _
   "The index of the OperationBinding of the " & _
   "Add operation : " & index.ToString())

注解

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

index如果 参数等于 Count,则会将 bindingOperation 参数添加到 的OperationBindingCollection末尾。

插入点后的元素向下移动以适应新元素。

适用于