选择列表中指定索引的值

Nar*_*esh 0 .net c#

我有一个列表,listInn多个元素调用.我有另一个列表,indmelements(m<n)调用它.ind是我想要保留的指数listIn,并删除其他指数.

我可以通过运行循环来做到这一点,但我很好奇是有一种聪明的方法来做到这一点.

例如.

listIn = [0,1,2,3,4,5,6,7,8,9,10]; // 11 elements
ind = [4,7,8] // 3 indices

Result = drop all elements excepts ones at 4,7,8. 
Run Code Online (Sandbox Code Playgroud)

Lee*_*Lee 7

listIn = ind.Select(i => listIn[i]).ToList();
Run Code Online (Sandbox Code Playgroud)