Mid Collections

How does the HashSet<T> differ from a List<T> or Dictionary<TKey, TValue>?

Feature HashSet<T> List<T> Dictionary<TKey,

TValue>

Allows

duplicates?

No Yes Keys: No; Values: Yes

Order No guaranteed

order

Maintains insertion

order

No guaranteed order

Lookup speed O(1) average O(n) O(1) average for keys

Key-value pairs No (only values) No Yes (key-value pairs)

More from C# Programming Tutorial

All questions for this course