Finding first index of element that matches a condition using LINQ

前端 未结 7 2012
闹比i
闹比i 2021-01-01 08:25
var item = list.Where(t => somecondition);

I would love to be able to find out the index of the element that was returned, in fact, in my case a

相关标签:
7条回答
  • 2021-01-01 09:25

    I'd need more context, but if you're just getting an index so that you can call .Skip, I would recommend taking a look at .SkipWhile.

    If you do really need the index, I'd suggest writing your own .IndexOf extension method.

    0 讨论(0)
提交回复
热议问题