假設:LINQ投影元素計數
var a = SomeCollection.OrderBy(...)
.Select(f => new MyType
{
counter = ? //I want counter value, so what first
//object have counter=1, second counter=2
//and so on
a=f.sometthing,
...
});
如何設置這個計數器值?或者我是否會在事後迭代a
?
此重載記錄在http://msdn.microsoft.com/en-us/library/bb534869.aspx – Reddog
@Reddog,謝謝,我已經添加了答案的鏈接。 –
這不適用於實體的linq,儘管 – ren