Easiest way to implement .Contains() on a ICollection<Tuple<T1,T2>>
Suppose I have a Dictionary<String, Tuple<T1,T2>>开发者_Python百科;
and I want to determine if the any of the dictionary values has V1 for its T1. How would I do this most elegantly?
Linq?
Well, this comes to mind:
var exists = dict.Values.Any(t => t.Item1 == v1);
bool b = dictionary.Any(item => item.Value.Item1 == searchTerm);
精彩评论