LINQ Group By into a Dictionary Object

前端 未结 4 393
野的像风
野的像风 2021-01-30 02:07

I am trying to use LINQ to create a Dictionary> from a List. I can get this to work using \"

4条回答
  •  再見小時候
    2021-01-30 02:41

    Dictionary> myDictionary = ListOfCustomObjects
        .GroupBy(o => o.PropertyName)
        .ToDictionary(g => g.Key, g => g.ToList());
    

提交回复
热议问题