Sunday, June 15, 2008

LINQ ToDictionary

If you want to convert an IEnumerable to a dictionary using LINQ then do:

Dictionary<string, object> dict = myList.ToDictionary(a => a.MyString, a => a.MyObject);

2 comments: