Find index of a value in an array

前端 未结 8 1551
傲寒
傲寒 2020-11-29 22:41

Can linq somehow be used to find the index of a value in an array?

For instance, this loop locates the key index within an array.

for (int i = 0; i &         


        
8条回答
  •  春和景丽
    2020-11-29 23:14

    int index = -1;
    index = words.Any (word => { index++; return word.IsKey; }) ? index : -1;
    

提交回复
热议问题