ssh*_*how 4 .net c# linq lambda
我有一个string[],并希望获得string[]具有索引的元素,其中我知道存在,在一个中指定int[].
string[] stringArray = { "a", "b", "c", "d", "e", "f", "g" };
int[] indices = { 1, 2, 4, 6 };
由此,我试图得到一个string[]包含{ "b", "c", "e", "g" }.优选使用λ表达.我该怎么做?
rec*_*ive 10
你能做到的一种方法就是这样.
string[] result = indices.Select(i => stringArray[i]).ToArray()
indices.Select(i => stringArray[i]);
| 归档时间: | 
 | 
| 查看次数: | 707 次 | 
| 最近记录: |