class AgeClass
{
string[] Names {get;set;}
int Age {get;set;}
}
...
IEnumerable<AgeClass> myList = ...; // a few instances of AgeClass
now i want to get (out of myList) a
IEnumerable<KeyValuePair<string,int>>
with a Pair of Name and Age. How to do this easily?
Note that you must be aware that linq is creating a query – each time you enumerate this collection new one will be created based on current state of
myList. To remove this effect simply add.ToList()to the end of this line.