MessagePartCollection.CopyTo(MessagePart[], Int32) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
複製整個 MessagePartCollection 至 MessagePart 型別的相容一維陣列,從目標陣列的指定以零起始的索引位置開始。
public:
void CopyTo(cli::array <System::Web::Services::Description::MessagePart ^> ^ array, int index);
public void CopyTo (System.Web.Services.Description.MessagePart[] array, int index);
member this.CopyTo : System.Web.Services.Description.MessagePart[] * int -> unit
Public Sub CopyTo (array As MessagePart(), index As Integer)
參數
- array
- MessagePart[]
MessagePart 型別的陣列,做為複製動作目的端。
- index
- Int32
以零起始的索引,要於此處開始放置複製的集合。
範例
下列範例示範 如何使用 CopyTo
方法。
Message^ myLocalMessage = myServiceDescription->Messages[ "AddHttpPostOut" ];
if ( myMessageCollection->Contains( myLocalMessage ) )
{
Console::WriteLine( "Message : {0}", myLocalMessage->Name );
// Get the message part collection.
MessagePartCollection^ myMessagePartCollection = myLocalMessage->Parts;
array<MessagePart^>^myMessagePart = gcnew array<MessagePart^>(myMessagePartCollection->Count);
// Copy the MessagePartCollection to an array.
myMessagePartCollection->CopyTo( myMessagePart, 0 );
for ( int k = 0; k < myMessagePart->Length; k++ )
Console::WriteLine( "\t Part Name : {0}", myMessagePartCollection[ k ]->Name );
Console::WriteLine( "" );
}
Message myLocalMessage = myServiceDescription.Messages["AddHttpPostOut"];
if (myMessageCollection.Contains(myLocalMessage))
{
Console.WriteLine("Message : " + myLocalMessage.Name);
// Get the message part collection.
MessagePartCollection myMessagePartCollection = myLocalMessage.Parts;
MessagePart[] myMessagePart =
new MessagePart[myMessagePartCollection.Count];
// Copy the MessagePartCollection to an array.
myMessagePartCollection.CopyTo(myMessagePart,0);
for(int k = 0; k < myMessagePart.Length; k++)
{
Console.WriteLine("\t Part Name : " +
myMessagePartCollection[k].Name);
}
Console.WriteLine("");
}
Dim myLocalMessage As Message = _
myServiceDescription.Messages("AddHttpPostOut")
If myMessageCollection.Contains(myLocalMessage) Then
Console.WriteLine("Message : " & myLocalMessage.Name)
' Get the message part collection.
Dim myMessagePartCollection As MessagePartCollection = _
myLocalMessage.Parts
Dim myMessagePart(myMessagePartCollection.Count) As MessagePart
' Copy the MessagePartCollection to an array.
myMessagePartCollection.CopyTo(myMessagePart, 0)
Dim k As Integer
For k = 0 To myMessagePart.Length - 2
Console.WriteLine(ControlChars.Tab & " Part Name : " & _
myMessagePartCollection(k).Name)
Next k
Console.WriteLine("")
End If