Omar Kooheji Omar Kooheji - 2 months ago 35
C# Question

C# Set collection?

Does anyone know if there is a good equivalent to Java's

Set
collection in C#? I know that you can somewhat mimic a set using a
Dictionary
or a
HashTable
by populating but ignoring the values, but that's not a very elegant way.

Answer

If you're using .NET 3.5, you can use HashSet<T>. It's true that .NET doesn't cater for sets as well as Java does though.

The Wintellect PowerCollections may help too.

Comments