Unique Tags with HashSet
HashSet<T> expresses uniqueness directly and supports fast membership tests.
How it works
Normalize and deduplicate tags.
A case-insensitive comparer prevents differently cased spellings from becoming separate tags.
Runnable C# example
Program.cs
using System;
using System.Collections.Generic;
class Program
{
static void Main()
{
var tags = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "C#", "dotnet", "c#" };
Console.WriteLine(tags.Count);
}
}
2Practice with the debugger
Set a breakpoint on an important assignment or condition, click Debug, and inspect the local values before stepping to the next line.