Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

HashSet<T>.IntersectWith Method

Modifies the current HashSet<T> object to contain only elements that are present in that object and in the specified collection.

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

public void IntersectWith(
	IEnumerable<T> other
)

Parameters

other
Type: System.Collections.Generic.IEnumerable<T>

The collection to compare to the current HashSet<T> object.

Implements

ISet<T>.IntersectWith(IEnumerable<T>)

ExceptionCondition
ArgumentNullException

other is null.

If the collection represented by the other parameter is a HashSet<T> collection with the same equality comparer as the current HashSet<T> object, this method is an O(n) operation. Otherwise, this method is an O(n + m) operation, where n is Count and m is the number of elements in other.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8

Portable Class Library

Supported in: Portable Class Library
Show:
© 2015 Microsoft