Get sum of the value from list using linq?

后端 未结 4 1203
-上瘾入骨i
-上瘾入骨i 2020-12-31 06:57

I am trying to get the sum of the value from list of list using linq ?my data is as below code

        List> allData = new List<         


        
4条回答
  •  春和景丽
    2020-12-31 07:27

    Sticking as much as possible to the LINQ query language:

    var grouped = from d in allData
                  group d by i[0] into g
                  select new
                  {
                      Name = g.Key,
                      Sum = g.Sum(i => int.Parse(i[2]))
                  };
    

提交回复
热议问题