PortCollection.IndexOf Method

Searches for the specified Port and returns the zero-based index of the first occurrence within the collection.

Namespace: System.Web.Services.Description
Assembly: System.Web.Services (in system.web.services.dll)

public:
int IndexOf (
	Port^ port
)
public int IndexOf (
	Port port
)
public function IndexOf (
	port : Port
) : int
Not applicable.

Parameters

port

The Port for which to search in the collection.

Return Value

A 32-bit signed integer.

myPortCollection = myService->Ports;

// Create an array of Port objects.
Console::WriteLine( "\nPort collection :" );
array<Port^>^myPortArray = gcnew array<Port^>(myService->Ports->Count);
myPortCollection->CopyTo( myPortArray, 0 );
for ( int i1 = 0; i1 < myService->Ports->Count; ++i1 )
{
   Console::WriteLine( "Port[{0}] : {1}", i1, myPortArray[ i1 ]->Name );

}
Port^ myIndexPort = myPortCollection[ 0 ];
Console::WriteLine( "\n\nThe index of port '{0}' is : {1}", myIndexPort->Name, myPortCollection->IndexOf( myIndexPort ) );

myPortCollection = myService.get_Ports();

// Create an array of Port objects.
Console.WriteLine("\nPort collection :");
Port myPortArray[] = 
     new Port[myService.get_Ports().get_Count()];
myPortCollection.CopyTo(myPortArray, 0);
for (int i1 = 0; i1 < myService.get_Ports().get_Count();
    ++i1) {
    Console.WriteLine("Port[" + i1 + "] : " 
        + myPortArray[i1].get_Name());
}

Port myIndexPort = myPortCollection.get_Item(0);
Console.WriteLine("\n\nThe index of port '" 
    + myIndexPort.get_Name() + "' is : " 
    + myPortCollection.IndexOf(myIndexPort));

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show: