Mid
From PDF
Collections
C# Collections
How do you iterate through a SortedSet<T>?
Short answer: Use a foreach loop which iterates over the elements in sorted ascending order: foreach (var item in sortedSet)
Example code
{ Console.WriteLine(item); }
Real-world example (ShopNest)
When applying a coupon, ShopNest keeps used coupon codes in a HashSet<string> so “already used?” checks stay fast and unique.
Say this in the interview
- Define — one clear sentence (the short answer above).
- Example — relate it to a project like ShopNest or your real work.
- Trade-off — when you would not use it.
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png