PortCollection.CopyTo(Port[], Int32) 方法

定义

将整个 PortCollection 复制到 Port 类型的一维数组中(从目标数组的指定的从零开始的索引处开始)。

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)

参数

array
Port[]

将作为复制操作目标的 Port 类型的数组。

index
Int32

将在该处开始放置所复制的集合的从零开始的索引。

示例

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

适用于