C# 14 · Collections and LINQ

Keep unique items

A set rejects duplicates, and Add returns false if the item was already there.

var seen = new HashSet<string>();
bool isNew = seen.Add("Ada");

Official C# 14 documentation

More collections and linq commands

All collections and linq commands · C# 14 cheatsheet

Was this page helpful?