Can I have an incrementing count variable in LINQ?

后端 未结 3 1051
没有蜡笔的小新
没有蜡笔的小新 2021-02-04 23:57

I want to do something like this:

from a in stuff
let counter = 0
select new { count = counter++, a.Name };

But I get a error telling me that c

3条回答
  •  粉色の甜心
    2021-02-05 00:27

    Just add two variable here NumberRow is for that

    .Select((x,NumberRow) => new ViewModelArchiveOrder
                        {
                            NumberRow= NumberRow + 1,
                        })
    

提交回复
热议问题