    

 ## On this page

  

 

 # Class ObservableHashSet&lt;T\\&gt;

 Last update: 16.07.2025 

Namespace: [VM.Collections](VM.Collections.md)  
Assembly: VM.dll

Represents an observable set of values.

```csharp
public sealed class ObservableHashSet<T> : HashSet<T>

```

#### Type Parameters

`T`

The type of elements in the hash set.

#### Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) ← [HashSet&lt;T&gt;](https://learn.microsoft.com/dotnet/api/system.collections.generic.hashset-1) ← [ObservableHashSet&lt;T&gt;](VM.Collections.ObservableHashSet-1.md)

## Constructors

### ObservableHashSet()

```csharp
public ObservableHashSet()

```

### ObservableHashSet(IEnumerable&lt;T&gt;)

```csharp
public ObservableHashSet(IEnumerable<T> collection)

```

#### Parameters

`collection` [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)&lt;T&gt;

### ObservableHashSet(IEqualityComparer&lt;T&gt;)

```csharp
public ObservableHashSet(IEqualityComparer<T> comparer)

```

#### Parameters

`comparer` [IEqualityComparer](https://learn.microsoft.com/dotnet/api/system.collections.generic.iequalitycomparer-1)&lt;T&gt;

### ObservableHashSet(IEnumerable&lt;T&gt;, IEqualityComparer&lt;T&gt;)

```csharp
public ObservableHashSet(IEnumerable<T> collection, IEqualityComparer<T> comparer)

```

#### Parameters

`collection` [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)&lt;T&gt;

`comparer` [IEqualityComparer](https://learn.microsoft.com/dotnet/api/system.collections.generic.iequalitycomparer-1)&lt;T&gt;

## Methods

### Add(T)

Adds the specified element to a set.

```csharp
public bool Add(T item)

```

#### Parameters

`item` T

The element to add to the set.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

true if the element is added to the  object; false if the element is already present.

### Clear()

Removes all elements from a  object.

```csharp
public void Clear()

```

### Dispose()

```csharp
public void Dispose()

```

### ExceptWith(IEnumerable&lt;T&gt;)

Removes all elements in the specified collection from the current  object.

```csharp
public void ExceptWith(IEnumerable<T> other)

```

#### Parameters

`other` [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)&lt;T&gt;

The collection of items to remove from the  object.

### IntersectWith(IEnumerable&lt;T&gt;)

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

```csharp
public void IntersectWith(IEnumerable<T> other)

```

#### Parameters

`other` [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)&lt;T&gt;

The collection to compare to the current  object.

### Remove(T)

Removes the specified element from a  object.

```csharp
public bool Remove(T item)

```

#### Parameters

`item` T

The element to remove.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

true if the element is successfully found and removed; otherwise, false. This method returns false if item is not found in the  object.

### Reset()

```csharp
public void Reset()

```

### SymmetricExceptWith(IEnumerable&lt;T&gt;)

Modifies the current  object to contain only elements that are present either in that object or in the specified collection, but not both.

```csharp
public void SymmetricExceptWith(IEnumerable<T> other)

```

#### Parameters

`other` [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)&lt;T&gt;

The collection to compare to the current  object.

### UnionWith(IEnumerable&lt;T&gt;)

Modifies the current  object to contain all elements that are present in itself, the specified collection, or both.

```csharp
public void UnionWith(IEnumerable<T> other)

```

#### Parameters

`other` [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)&lt;T&gt;

The collection to compare to the current  object.

### CollectionChanged

```csharp
public event NotifyCollectionChangedEventHandler CollectionChanged

```

#### Event Type

[NotifyCollectionChangedEventHandler](https://learn.microsoft.com/dotnet/api/system.collections.specialized.notifycollectionchangedeventhandler)