共用方式為


ImportCollection.CopyTo(Import[], Int32) 方法

定義

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

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

參數

array
Import[]

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

index
Int32

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

範例

下列範例示範 CopyTo 方法的用法。

array<Import^>^myImports = gcnew array<Import^>(myServiceDescription->Imports->Count);

// Copy 'ImportCollection' to an array.
myServiceDescription->Imports->CopyTo( myImports, 0 );
Console::WriteLine( "Imports that are copied to Importarray ..." );
for ( int i = 0; i < myImports->Length; ++i )
   Console::WriteLine( "\tImport Namespace : {0} Import Location : {1} ",
      myImports[ i ]->Namespace, myImports[ i ]->Location );
Import[] myImports = new Import[myServiceDescription.Imports.Count];
// Copy 'ImportCollection' to an array.
myServiceDescription.Imports.CopyTo(myImports,0);
Console.WriteLine("Imports that are copied to Importarray ...");
for(int i=0;i < myImports.Length; ++i)
   Console.WriteLine("\tImport Namespace :{0} Import Location :{1} "
                                          ,myImports[i].Namespace
                                          ,myImports[i].Location);
Dim myImports(myServiceDescription.Imports.Count - 1) As Import
' Copy 'ImportCollection' to an array.
myServiceDescription.Imports.CopyTo(myImports, 0)
Console.WriteLine("Imports that are copied to Importarray ...")
Dim j As Integer
For j = 0 To myImports.Length - 1
   Console.WriteLine(ControlChars.Tab + _
                     "Import Namespace :{0} Import Location :{1} ", _
                     myImports(j).Namespace, myImports(j).Location)
Next j

適用於