C# Set collection?

Omar Kooheji picture Omar Kooheji · Oct 8, 2008 · Viewed 379k times · Source

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

Jon Skeet picture Jon Skeet · Oct 8, 2008

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.