Edit

Share via


ImportCollection.CopyTo(Import[], Int32) Method

Definition

Copies the entire ImportCollection to a compatible one-dimensional array of type Import, starting at the specified zero-based index of the target array.

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)

Parameters

array
Import[]

An array of type Import serving as the destination of the copy action.

index
Int32

The zero-based index at which to start placing the copied collection.

Examples

The following example demonstrates the use of the CopyTo method.

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

Applies to