Create a dictionary on a list with grouping

前端 未结 4 1606
被撕碎了的回忆
被撕碎了的回忆 2020-12-04 08:51

I have the following object in a list:

public class DemoClass
{
    public int GroupKey { get; set; }
    public string DemoString { get; set; }
    public o         


        
4条回答
  •  日久生厌
    2020-12-04 09:34

    You already made it a one-liner. Just put the ToDictionary at the end of your first line. If you want it to be shorter, use the functional composition syntax instead of the query syntax.

提交回复
热议问题