我一直在挣扎。
我该怎么写:
/* initialization */
List<Tuple<string, string, string>> mytuples = new List<Tuple<string, string, string>>();
// pseudocode:
if(mytuples.Contains("hello") in Item2)
{
Console.Write("Success");
}
/* initialization */
List<Tuple<string, string, string>> mytuples = new List<Tuple<string, string, string>>();
bool containsHello = mytuples.Any(c=>c.Item2.Contains("hello"));
if(containsHello )
{
Console.Write("Success");
}
您可以使用 linq 来检查它:
List<Tuple<string, string, string>> mytuples = new List<Tuple<string, string, string>>();
if(mytuples.Where(t=>t.Item2.Contains("hello")).Any())
Console.Write("Success");