This documentation is archived and is not being maintained.
MessageCollection.CopyTo Method
.NET Framework 1.1
Copies the entire MessageCollection to a compatible one-dimensional array of type Message, starting at the specified zero-based index of the target array.
[Visual Basic] Public Sub CopyTo( _ ByVal array() As Message, _ ByVal index As Integer _ ) [C#] public void CopyTo( Message[] array, int index ); [C++] public: void CopyTo( Message* array[], int index ); [JScript] public function CopyTo( array : Message[], index : int );
Parameters
- array
- An array of type Message serving as the destination for 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 the use of the CopyTo method.
[Visual Basic] ' Create a Message Array. Dim myMessages(myServiceDescription.Messages.Count) As Message ' Copy MessageCollection to an array. myServiceDescription.Messages.CopyTo(myMessages, 0) Console.WriteLine("") Console.WriteLine("Displaying Messages that were copied to Messagearray ...") Console.WriteLine("") For i = 0 To myMessageCollection.Count - 1 Console.WriteLine("Message Name : " + myMessages(i).Name) Next [C#] // Create a Message Array. Message[] myMessages = new Message[myServiceDescription.Messages.Count]; // Copy MessageCollection to an array. myServiceDescription.Messages.CopyTo(myMessages,0); Console.WriteLine(""); Console.WriteLine("Displaying Messages that were copied to Messagearray ..."); Console.WriteLine(""); for(int i=0;i < myServiceDescription.Messages.Count; ++i) { Console.WriteLine("Message Name : " + myMessages[i].Name); } [C++] // Create a Message Array. Message* myMessages[] = new Message*[myServiceDescription->Messages->Count]; // Copy MessageCollection to an array. myServiceDescription->Messages->CopyTo(myMessages, 0); Console::WriteLine(S""); Console::WriteLine(S"Displaying Messages that were copied to Messagearray ..."); Console::WriteLine(S""); for (int i=0;i < myServiceDescription->Messages->Count; ++i) Console::WriteLine(S"Message Name : {0}", myMessages[i]->Name);
[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
MessageCollection Class | MessageCollection Members | System.Web.Services.Description Namespace
Show: