Answers for "linq select count group by c#"

C#
3

linq select count group by c#

foreach(var line in data.GroupBy(info => info.metric)
                        .Select(group => new { 
                             Metric = group.Key, 
                             Count = group.Count() 
                        })
                        .OrderBy(x => x.Metric))
{
     Console.WriteLine("{0} {1}", line.Metric, line.Count);
}
Posted by: Guest on January-22-2021

C# Answers by Framework

Browse Popular Code Answers by Language