简体   繁体   中英

How would i count the frequency of a number on an List<double> in C#?

I have an IList<double> and i'm trying to find the most frequent value inside the list, as well as the frequency of each of the numbers on the list, but how would it work in a way that I get something like an IDictionary<number, frequency> of each value?

Thanks :)

var dictionary= list.GroupBy(x => x).ToDictionary(x => x.Key, x => x.Count());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM