Use the overload of Select
which includes the index:
var highIndexes = list.Select((value, index) => new { value, index })
.Where(z => z.value > 10)
.Select(z => z.index);
The steps in turn:
- Project the sequence of values into a sequence of value/index pairs
- Filter to only include pairs where the value is greater than 10
- Project the result to a sequence of indexes
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…