METHOD

HashSet.Add

Returns true if a new member was added and false if an equal member already exists.

Formal Syntax & Structure

csharp syntaxcsharp
bool Add(T item)

Working Example

Example Snippetcsharp
using System.Collections.Generic;var ids = new HashSet<int> { 4 };System.Console.WriteLine(ids.Add(4));
C# & .NET Reference