如何根据条件获取List中项的index集合

  有时可能需要需要获取一个List中符合某条件的项的index集合,可以使用如下Linq语句:

 

var query = source.Select((value, index) => new { value, index }).Where(x => x.value => Condition(value)).Select(x => x.index);

 

posted on 2011-10-31 21:35  齐世昌  阅读(1347)  评论(0编辑  收藏  举报