public static T2 GetValueAtKey <T1, T2>(this IDictionary <T1, T2> originalDictionary, T1 key) { if (key != null) { if (originalDictionary.ContainsKey(key)) { return(originalDictionary.FirstOrDefault(x => x.Key.Equals(key)).Value); } else { throw new KeyNotFoundException(); } } else { throw new ArgumentNullException(); } }