This documentation is archived and is not being maintained.

ServiceDescriptionCollection.Contains Method

Returns a value indicating whether the specified ServiceDescription is a member of the collection.

[Visual Basic]
Public Function Contains( _
   ByVal serviceDescription As ServiceDescription _
) As Boolean
[C#]
public bool Contains(
 ServiceDescription serviceDescription
);
[C++]
public: bool Contains(
 ServiceDescription* serviceDescription
);
[JScript]
public function Contains(
   serviceDescription : ServiceDescription
) : Boolean;

Parameters

serviceDescription
The ServiceDescription for which to check collection membership.

Return Value

true if the serviceDescription parameter is a member of the ServiceDescriptionCollection; otherwise false.

Example

[Visual Basic] 
' Check for a ServiceDescription in the collection.
If myCollection.Contains(myServiceDescription2) Then
   ' Get the index of a ServiceDescription.
   Dim myIndex As Integer = myCollection.IndexOf(myServiceDescription2)

   ' Remove a ServiceDescription from the collection.
   myCollection.Remove(myServiceDescription2)
   Console.WriteLine("Element at index {0} is removed.", _
      myIndex.ToString())
Else
   Console.WriteLine("Element not found.")
End If

[C#] 
// Check for a ServiceDescription in the collection.
if (myCollection.Contains(myServiceDescription2))
{ 
   // Get the index of a ServiceDescription.
   int myIndex = myCollection.IndexOf(myServiceDescription2);
 
   // Remove a ServiceDescription from the collection.
   myCollection.Remove(myServiceDescription2);
   Console.WriteLine("Element at index {0} is removed.", myIndex);
}
else
{
   Console.WriteLine("Element not found.");
}

[C++] 
// Check for 'ServiceDescription' object in the collection.
if (myCollection->Contains(myServiceDescription2)) 
{
   // Get the index of 'ServiceDescription' object.
   int myIndex = myCollection->IndexOf(myServiceDescription2);
   // Remove 'ServiceDescription' object from the collection.
   myCollection->Remove(myServiceDescription2);
   Console::WriteLine(S"Element at index {0} is removed ",__box( myIndex));
} 
else
   Console::WriteLine(S"Element not found.");

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter 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

ServiceDescriptionCollection Class | ServiceDescriptionCollection Members | System.Web.Services.Description Namespace

Show: