Reputation: 59939
I am saving multiple tuples that contain strings in a list:
List<Tuple<string, string, string>> ExcelRawImport
What i want to do now, is find the tuple in the list, where the Tuple.Item1
has an specific value.
how should i do this ?
Upvotes: 1
Views: 8981
Reputation: 35544
With Linq I would say
var specificValue = "mySpecificValue";
var foundTuple = ExcelRawImport.FirstOrDefault(eri => eri.Item1 == specificValue);
This returns the first Item from your list that matches the specific value. If no matching value is found, foundTuple is null.
If you need all items that match you can use the Where() statement instead.
var foundTuples = ExcelRawImport.Where(eri => eri.Item1 == specificValue).ToList();
Upvotes: 8