How to call Dictionary<K, V>.TryGetValue() where K : Predicate<T>, V : enum
问题 I have Dictionary<Predicate<double>, SomeEnum> : var dic = new Dictionary<Predicate<double>, SomeEnum> { { (d) => d < 10, SomeEnum.Foo }, { (d) => d > 90, SomeEnum.Bar } }; I want to call TryGetValue(K, out V) against it like this: dic.TryGetValue(99) and receive SomeStruct.Bar But first param for TryGetValue() is Predicate<T> , not just T . How can I do what I want? I found only a dirty workaround: var kpv = dic.FirstOrDefault(p => p.Key(99)); if (kpv.Key != null) var result = kpv.Value; Are