This documentation is archived and is not being maintained.
PortCollection.CopyTo Method
.NET Framework 1.1
Copies the entire PortCollection to a one-dimensional array of type Port, starting at the specified zero-based index of the target array.
[Visual Basic] Public Sub CopyTo( _ ByVal array() As Port, _ ByVal index As Integer _ ) [C#] public void CopyTo( Port[] array, int index ); [C++] public: void CopyTo( Port* array[], int index ); [JScript] public function CopyTo( array : Port[], index : int );
Parameters
- array
- An array of type Port serving as the destination for the copy action.
- index
- The zero-based index at which to start placing the copied collection.
Example
[Visual Basic] 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 [C#] 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); } [C++] myPortCollection = myService->Ports; // Create an array of Port objects. Console::WriteLine(S"\nPort collection :"); Port* myPortArray[] = new Port*[myService->Ports->Count]; myPortCollection->CopyTo(myPortArray, 0); for(int i1=0 ; i1 < myService->Ports->Count ; ++i1) { Console::WriteLine(S"Port[{0}] : {1}", __box(i1), myPortArray[i1]->Name); }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
See Also
PortCollection Class | PortCollection Members | System.Web.Services.Description Namespace
Show: