Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

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);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #linq #select #count #group
ADD COMMENT
Topic
Name
5+4 =