using System.Diagnostics;
static void Main(string[] args)
var dic = Enumerable.Range(0, TOTAL).ToDictionary(c => c, c => c);
var stopwatch = new Stopwatch();
for (var i = 0; i < TOTAL; i++)
Console.Out.WriteLine("To Search in dictionary = " + stopwatch.ElapsedTicks);
for (var i = 0; i < TOTAL; i++)
Console.Out.WriteLine("To fail search with try/catch in dictionary = " + stopwatch.ElapsedTicks);
for (var i = 0; i < TOTAL; i++)
if (!dic.TryGetValue(i + TOTAL, out int value))
Console.Out.WriteLine("To fail search without try/catch in dictionary = " + stopwatch.ElapsedTicks);