我有一个 Linq 列表。我想选择某一行。我必须通过 foreach 循环来遍历行以获取指定的行,还是有其他方法。
我不想要的是...
编辑
specifiedRow = 13;
-
var linqList = from a in random.List
where (a.id == idNum)
select new {a.id, a.name, a.address};
int counter = 0;
foreach (var item in linqList) {
if(counter == specifiedRow) {
//do stuff
}
}
What I would like...
var linqList = from a in random.List
where (a.id == idNum)
//row is specified row in linqList
select new {a.id, a.name, a.address};