using System.Collections.Generic;
using System.Diagnostics;
const int _max = 10000000;
public static void Main()
var h = new HashSet<string>(StringComparer.Ordinal);
var d = new Dictionary<string, bool>(StringComparer.Ordinal);
var a = new string[] { "a", "b", "c", "d", "longer", "words", "also" };
var s1 = Stopwatch.StartNew();
for (int i = 0; i < _max; i++)
var s2 = Stopwatch.StartNew();
for (int i = 0; i < _max; i++)
Console.WriteLine(h.Count);
Console.WriteLine(d.Count);
Console.WriteLine("HashSet ====> " + ((double)(s1.Elapsed.TotalMilliseconds * 1000000) /_max).ToString("0.00 ns"));
Console.WriteLine("Dictionary ====> " + ((double)(s2.Elapsed.TotalMilliseconds * 1000000) /_max).ToString("0.00 ns"));