How do I select items from an array using an array of indices with Linq?
Following code works:
String[] A = new String[] { "one", "two", "three", "four" };
int[] idxs = new int[] { 1, 3 };
String[] B = new String[idxs.Length];
for (int i = 0; i < idxs.Length; i++)
{
B[i] = A[idxs[i]];
}
System.Diagnostics.Debug.WriteLine(String.Join(", ", B));
output:
two, four
Is there a LINQ way (or other one-liner) to get rid of the for loop?