int array to frequency dictionary c#

85

int array to frequency dictionary c# -

using System.Linq;

List<int> ids = //

foreach(var grp in ids.GroupBy(i => i))
{
    Console.WriteLine("{0} : {1}", grp.Key, grp.Count());
}

int array to frequency dictionary c# -

var frequency = myList.GroupBy(x => x).ToDictionary(x => x.Key, x => x.Count());

Comments

Submit
0 Comments