I have a list in C# called MyList
:
List<Tuple<string, int, int>> MyList= new List<Tuple<string, int, int>>()
{
Tuple.Create("Cars", 22, 3),
Tuple.Create("Cars", 28, 5),
Tuple.Create("Planes", 33, 6)
};
I want to loop through the whole list in the same order as I filled it above and be able to get the values one by one for each list item, like Cars, 22, 3
. How do I do that? I guess I have to use ForEach
somehow.
ForEach
method with an incorrect lambda syntax.foreach(var ... in MyList){ ... }
is a loop – Eumenidesfor
loop as it is in my answer below. – Playhouse