C# Data Structure Like Dictionary But Without A Value

Solution 1:

Yes, it's called a HashSet<T>, and available in version 3.5 of the .NET framework. If you use .NET version 2.0, you can use a Dictionary and set values to null.

Solution 2:

If 3.5 is not an option you could do something like Dictionary < int, int > and simply ignore the value. i've done this in 2.0 and i tend to set the value to the same as the key.

Solution 3:

If you're not targeting .NET 3.5, Power Collections (open source) also provides a Set implementation.