MessagePartCollection.Insert(Int32, MessagePart) 方法

定义

将指定的 MessagePart 添加到 MessagePartCollection 中指定的从零开始的索引处。Adds the specified MessagePart to the MessagePartCollection at the specified zero-based index.

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

参数

index
Int32

将在该处插入 messagePart 参数的从零开始的索引。The zero-based index at which to insert the messagePart parameter.

messagePart
MessagePart

要添加到集合中的 MessagePartThe MessagePart to add to the collection.

示例

MessagePart^ myMessagePart1 = gcnew MessagePart;
myMessagePart1->Name = "parameters";
myMessagePart1->Element = gcnew XmlQualifiedName( "Add",myServiceDescription->TargetNamespace );
myMessage1->Parts->Insert( 0, myMessagePart1 );
MessagePart myMessagePart1 = new MessagePart();
myMessagePart1.Name = "parameters";
myMessagePart1.Element = new XmlQualifiedName("Add",myServiceDescription.TargetNamespace);
myMessage1.Parts.Insert(0,myMessagePart1);
Dim myMessagePart1 As New MessagePart()
myMessagePart1.Name = "parameters"
myMessagePart1.Element = New XmlQualifiedName("Add", _
   myServiceDescription.TargetNamespace)
myMessage1.Parts.Insert(0, myMessagePart1)

注解

如果集合中的项数已等于集合的容量,则会在插入新元素之前自动重新分配内部数组,从而使容量加倍。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.

如果 index 参数等于 Count ,则将 messagePart 参数添加到的末尾 MessagePartCollectionIf the index parameter is equal to Count, the messagePart parameter is added to the end of the MessagePartCollection.

插入点之后的元素向下移动以容纳新元素。The elements after the insertion point move down to accommodate the new element.

适用于