MessageCollection.CopyTo Method

Copies the entire MessageCollection to a compatible one-dimensional array of type Message, starting at the specified zero-based index of the target array.

Namespace: System.Web.Services.Description
Assembly: System.Web.Services (in system.web.services.dll)

public:
void CopyTo (
	array<Message^>^ array, 
	int index
)
public void CopyTo (
	Message[] array, 
	int index
)
public function CopyTo (
	array : Message[], 
	index : int
)
Not applicable.

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.

The following example demonstrates the use of the CopyTo method.

// Create a Message Array.
array<Message^>^myMessages = gcnew array<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 : {0}", myMessages[ i ]->Name );

// Create a Message Array.
Message myMessages[] = 
    new Message[myServiceDescription.get_Messages().get_Count()];

// Copy MessageCollection to an array.
myServiceDescription.get_Messages().CopyTo(myMessages, 0);
Console.WriteLine("");
Console.WriteLine("Displaying Messages that were copied to "
    + "Messagearray...");
Console.WriteLine("");
for (int i = 0; i < myServiceDescription.get_Messages().get_Count(); 
    ++i) {
    Console.WriteLine("Message Name : " 
        + ((Message)myMessages.get_Item(i)).get_Name());
}

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show: