次の方法で共有


ServiceCollection.CopyTo(Service[], Int32) メソッド

定義

ServiceCollection 型の 1 次元配列に、その配列内の指定した 0 から始まるインデックスを開始位置として Service 全体をコピーします。

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

コピーされたコレクションの貼り付け開始位置を示す、0 から始まるインデックス番号。

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

適用対象