public static void KeysAndValuesAsDelegate() { IDictionary <string, int> dict = new Dictionary <string, int>() { { "one", 1 }, { "two", 2 } }; Equal(new HashSet <string>(new[] { "one", "two" }), Enumerable.ToHashSet(dict.KeysGetter().Invoke())); Equal(new HashSet <int>(new[] { 1, 2 }), Enumerable.ToHashSet(dict.ValuesGetter().Invoke())); }