Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
 HashSet Collection Type

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Developer's Guide
HashSet Collection Type

The HashSet<(Of <(T>)>) class is a set collection that implements the ICollection interface and the ICollection<(Of <(T>)>) generic interface.

In mathematics, a set is a collection of distinct objects that is usually defined by a rule that determines whether an element is a member of a particular set. For example, a set could be defined to contain "all the odd numbers between 1 and 21" or the numbers "1, 3, 5 and 7".

The HashSet<(Of <(T>)>) class is based on the model of mathematical sets and provides high-performance set operations similar to accessing the keys of the Dictionary<(Of <(TKey, TValue>)>) or Hashtable collections. In simple terms, the HashSet<(Of <(T>)>) class can be thought of as a Dictionary<(Of <(TKey, TValue>)>) collection without values.

A HashSet<(Of <(T>)>) collection is not sorted and cannot contain duplicate elements. If order or element duplication is more important than performance for your application, consider using the List<(Of <(T>)>) class together with the Sort method.

HashSet<(Of <(T>)>) provides many mathematical set operations, such as set addition (unions) and set subtraction. The following table lists the provided HashSet<(Of <(T>)>) operations and their mathematical equivalents.

HashSet(Of T) operation

Mathematical equivalent

UnionWith

Union or set addition

IntersectWith

Intersection

ExceptWith

Set subtraction

SymmetricExceptWith

Symmetric difference

In addition to the listed set operations, the HashSet<(Of <(T>)>) class also provides methods for determining set equality, overlap of sets, and whether a set is a subset or superset of another set.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker