I have a DataRow: Row[1, 2, 3, 4, ...]
I also have an array of primary key column names: PKeys[1, 2, ...]
I want an array or list which has an element for each PKeys element containing the value (string) from the matching elements in the DataRow.
Of course I could do this:
List<string> keyVals = new List<string>();
foreach (string PKey in PKeys)
{
keyVals.Add(Row[PKey].ToString());
}
but is there a more elegant method, maybe with LINQ?
Thanks
Try this: