共用方式為


ServiceCollection.CopyTo(Service[], Int32) 方法

定義

複製整個 ServiceCollectionService 型別的一維陣列,從目標陣列的指定以零起始的索引位置開始。

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

參數

array
Service[]

做為複製動作目的端的 Service 型別的陣列。

index
Int32

以零起始的索引,要於此處開始放置複製的集合。

範例

array<Service^>^myServiceArray = gcnew array<Service^>(myServiceDescription->Services->Count);

// Copy the services into an array.
myServiceDescription->Services->CopyTo( myServiceArray, 0 );
IEnumerator^ myEnumerator = myServiceArray->GetEnumerator();
Console::WriteLine( "The names of services in the array are" );
while ( myEnumerator->MoveNext() )
{
   Service^ myService1 = dynamic_cast<Service^>(myEnumerator->Current);
   Console::WriteLine( myService1->Name );
}
Service[] myServiceArray =
   new Service[myServiceDescription.Services.Count];

// Copy the services into an array.
myServiceDescription.Services.CopyTo(myServiceArray,0);
IEnumerator myEnumerator = myServiceArray.GetEnumerator();
Console.WriteLine("The names of services in the array are");
while(myEnumerator.MoveNext())
{
   Service myService1 = (Service)myEnumerator.Current;
   Console.WriteLine(myService1.Name);
}
Dim myServiceArray(myServiceDescription.Services.Count - 1) _
As Service

' Copy the services into an array.
myServiceDescription.Services.CopyTo(myServiceArray, 0)
Dim myEnumerator As IEnumerator = myServiceArray.GetEnumerator()
Console.WriteLine("The names of services in the array are")
While myEnumerator.MoveNext()
   Dim myService1 As Service = CType(myEnumerator.Current, Service)
   Console.WriteLine(myService1.Name)
End While

適用於