The easiest way to implement .Contains () on ICollection <Tuple <T1, T2 >>

Suppose I have a Dictionary<String, Tuple<T1,T2>> , and I want to determine if the dictionary value has a V1 value for my T1. How can I do this most elegantly?

Linq?

+3
source share
2 answers

Well, it comes to mind:

 var exists = dict.Values.Any(t => t.Item1 == v1); 
+6
source
 bool b = dictionary.Any(item => item.Value.Item1 == searchTerm); 
+3
source

Source: https://habr.com/ru/post/1400947/


All Articles