This documentation is archived and is not being maintained.
ServiceCollection.Contains Method
.NET Framework 1.1
Returns a value indicating whether the specified Service instance is a member of the ServiceCollection.
[Visual Basic] Public Function Contains( _ ByVal service As Service _ ) As Boolean [C#] public bool Contains( Service service ); [C++] public: bool Contains( Service* service ); [JScript] public function Contains( service : Service ) : Boolean;
Parameters
- service
- The Service for which to check collection membership.
Return Value
true if the service parameter is a member of the ServiceCollection; otherwise, false.
Example
[Visual Basic] If myServiceDescription.Services.Contains(myService) Then Console.WriteLine( _ "The mentioned service Exists at index {0} in the WSDL.", _ myServiceDescription.Services.IndexOf(myService)) Dim myServiceArray(myServiceDescription.Services.Count - 1) _ As Service ' Copy the services into an array. myServiceDescription.Services.CopyTo(myServiceArray, 0) Dim myEnumerator As IEnumerator = myServiceArray.GetEnumerator() Console.WriteLine("The names of services in the array are") While myEnumerator.MoveNext() Dim myService1 As Service = CType(myEnumerator.Current, Service) Console.WriteLine(myService1.Name) End While Else Console.WriteLine("Service does not exist in the WSDL.") End If [C#] if(myServiceDescription.Services.Contains(myService)) { Console.WriteLine( "The mentioned service exists at index {0} in the WSDL.", myServiceDescription.Services.IndexOf(myService)); Service[] myServiceArray = new 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 = (Service)myEnumerator.Current; Console.WriteLine(myService1.Name); } } else { Console.WriteLine("Service does not exist in the WSDL." ); } [C++] if(myServiceDescription->Services->Contains(myService)) { Console::WriteLine( S"The mentioned service exists at index {0} in the WSDL.", __box(myServiceDescription->Services->IndexOf(myService))); Service* myServiceArray[] = new Service*[myServiceDescription->Services->Count]; // Copy the services into an array. myServiceDescription->Services->CopyTo(myServiceArray,0); IEnumerator* myEnumerator = myServiceArray->GetEnumerator(); Console::WriteLine(S"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(S"Service does not exist in the WSDL." ); }
[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
ServiceCollection Class | ServiceCollection Members | System.Web.Services.Description Namespace
Show: