ServiceCollection.IndexOf Method

Searches for the specified Service and returns the zero-based index of the first occurrence within the ServiceCollection.

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

public:
int IndexOf (
	Service^ service
)
public int IndexOf (
	Service service
)
public function IndexOf (
	service : Service
) : int
Not applicable.

Parameters

service

The Service for which to search in the collection.

Return Value

A 32-bit signed integer.

if ( myServiceDescription->Services->Contains( myService ) )
{
   Console::WriteLine( "The mentioned service exists at index {0} in the WSDL.", myServiceDescription->Services->IndexOf( myService ) );

   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 );
   }
}
else
{
   Console::WriteLine( "Service does not exist in the WSDL." );
}

if (myServiceDescription.get_Services().Contains(myService)) {
    Console.WriteLine("The mentioned service exists at index {0}"
        + "in the WSDL.", 
        System.Convert.ToString(myServiceDescription.get_Services().
        IndexOf(myService)));
    Service myServiceArray[] = new Service[myServiceDescription.
        get_Services().get_Count()];
    // Copy the services into an array.
    myServiceDescription.get_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.get_Current());
        Console.WriteLine(myService1.get_Name());
    }
}
else {
    Console.WriteLine("Service does not exist in the WSDL.");
}

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: