HashSet<T>::Contains Method (T)

 

Determines whether a HashSet<T> object contains the specified element.

Namespace:   System.Collections.Generic
Assembly:  System.Core (in System.Core.dll)

public:
virtual bool Contains(
	T item
) sealed

Parameters

item
Type: T

The element to locate in the HashSet<T> object.

Return Value

Type: System::Boolean

true if the HashSet<T> object contains the specified element; otherwise, false.

This method is an O(1) operation.

The following example demonstrates how to remove values from a HashSet<T> collection using the Remove method. In this example, the Contains method verifies that the set contains a value before removing it.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 8
.NET Framework
Available since 3.5
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 4.0
Windows Phone Silverlight
Available since 8.0
Windows Phone
Available since 8.1
Return to top
Show: