This documentation is archived and is not being maintained.
MessagePartCollection.CopyTo Method
.NET Framework 1.1
Copies the entire MessagePartCollection to a compatible one-dimensional array of type MessagePart, starting at the specified zero-based index of the target array.
[Visual Basic] Public Sub CopyTo( _ ByVal array() As MessagePart, _ ByVal index As Integer _ ) [C#] public void CopyTo( MessagePart[] array, int index ); [C++] public: void CopyTo( MessagePart* array[], int index ); [JScript] public function CopyTo( array : MessagePart[], index : int );
Parameters
- array
- An array of type MessagePart serving as the destination of the copy action.
- index
- The zero-based index at which to start placing the copied collection.
Example
[Visual Basic, C#, C++] The following example demonstrates a use of the CopyTo method.
[Visual Basic] 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 [C#] 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(""); } [C++] Message* myLocalMessage = myServiceDescription->Messages->Item[S"AddHttpPostOut"]; if (myMessageCollection->Contains(myLocalMessage)) { Console::WriteLine(S"Message : {0}", 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(S"\t Part Name : {0}", myMessagePartCollection->Item[k]->Name); Console::WriteLine(S""); }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
See Also
MessagePartCollection Class | MessagePartCollection Members | System.Web.Services.Description Namespace
Show: