我在C#中有一个列表,叫做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)
};
我希望能够按照上面填写列表的顺序循环整个列表,并且能够逐个获取每个列表项的值,例如 Cars, 22, 3
。我该怎么做呢?我想我必须以某种方式使用ForEach
。
};`
- KGB91ForEach
方法。foreach(var ... in MyList){ ... }
才是一个循环。 - Panagiotis Kanavosfor
循环。 - LopDev