Let's say I have an arbitray list of A
class A
{
string K {get;set;}
string V {get;set;}
}
...
List<A> theList = ...
Is there an easy way to compose a dictionary from theList? (something like the following)
Dictionary<string, string> dict = magic(x => x.K, x => x.V, theList)
I don't want to write the following code:
var d = new Dictionary<string, string>
foreach(var blah in theList)
d[blah.K] = blah.V