PortCollection.CopyTo(Port[], Int32) Methode

Definition

Kopiert die gesamte PortCollection in ein eindimensionales Array vom Typ Port, wobei am angegebenen nullbasierten Index des Zielarrays begonnen wird.

public:
 void CopyTo(cli::array <System::Web::Services::Description::Port ^> ^ array, int index);
public void CopyTo (System.Web.Services.Description.Port[] array, int index);
member this.CopyTo : System.Web.Services.Description.Port[] * int -> unit
Public Sub CopyTo (array As Port(), index As Integer)

Parameter

array
Port[]

Ein Array vom Typ Port, das als Ziel des Kopiervorgangs fungiert.

index
Int32

Der nullbasierte Index, an dem mit dem Platzieren der kopierten Auflistung begonnen werden soll.

Beispiele

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 );

}
myPortCollection = myService.Ports;

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

' Create an array of Port objects.
Console.WriteLine(ControlChars.NewLine & "Port collection :")
Dim myPortArray(myService.Ports.Count) As Port
myPortCollection.CopyTo(myPortArray, 0)
Dim i1 As Integer
For i1 = 0 to myService.Ports.Count -1
   Console.WriteLine("Port[" & i1.ToString + "] : " & _
      myPortArray(i1).Name)
Next

Gilt für: