Dictionary<TKey, TValue> finding key: try/catch vs TryGetValue

Today I saw some code where the developer accessed a dictionary like this: void Foo(int keyToFindInDictionary) {     Dictionary<int, string> dictionary = new Dictionary<int, string>();       try     {         DoSomethingWithTheResult(dictionary[keyToFindInDictionary]);     }     catch (KeyNotFoundException)     {         // fallback     } }   private void DoSomethingWithTheResult(string s) {     // do something } As you can see he catches the exception to […]