PortCollection::CopyTo Method (array<Port^>^, Int32)

 

Copies the entire PortCollection to a one-dimensional array of type Port, 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<Port^>^ array,
	int index
)

Parameters

array
Type: array<System.Web.Services.Description::Port^>^

An array of type Port serving as the destination for the copy action.

index
Type: System::Int32

The zero-based index at which to start placing the copied collection.

myPortCollection = myService->Ports;

// Create an array of Port objects.
Console::WriteLine( "\nPort collection :" );
array<Port^>^myPortArray = gcnew array<Port^>(myService->Ports->Count);
myPortCollection->CopyTo( myPortArray, 0 );
for ( int i1 = 0; i1 < myService->Ports->Count; ++i1 )
{
   Console::WriteLine( "Port[{0}] : {1}", i1, myPortArray[ i1 ]->Name );

}

.NET Framework
Available since 1.1
Return to top
Show: