Search in Item2 in the <Tuple> List
I fought.
How can I write:
/* initialization */ List<Tuple<string, string, string>> mytuple = new List<Tuple<string, string, string>>(); //pseudocode if(mytuple.Contains("hello") in Item2) { Console.Write("Success"); } +2
Stefan Donchev
source share2 answers
/* initialization */ List<Tuple<string, string, string>> mytuple = new List<Tuple<string, string, string>>(); bool containsHello = mytuple.Any(c=>c.Item2.Contains("hello")); if(containsHello ) { Console.Write("Success"); } +10
Sawan
source shareYou can use linq to check it:
List<Tuple<string, string, string>> mytuple = new List<Tuple<string, string, string>>(); if(mytuple.Where(t=>t.Item2.Contains("hello")).Any()) Console.Write("Success"); +4
Kirill Bestemyanov
source share