In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article shows you how to use C# statistical results ranking, the content is concise and easy to understand, can definitely brighten your eyes, through the detailed introduction of this article, I hope you can get something.
Public class Consult
{
Public string Name {get; set;}
Public int Times {get; set;}
Public int Rank {get; set;}
} var consults = new List ()
{
New Consult () {Name = "Zhang San", Times = 1}
New Consult () {Name = "Li Si", Times = 1}
New Consult () {Name = "Wang Wu", Times = 2}
New Consult () {Name = "Zhao Liu", Times = 3}
New Consult () {Name = "Xiaoming", Times = 0}
New Consult () {Name = "Xiao Hong", Times = 0}
}
We have got the number of times and names of all doctors consulted, and then we continue to operate them through LINQ. The most important thing to understand here is that projection (Select or SelectMany) has an index parameter, and everything will be easy to know if there is an index, because the higher the number of times, the higher the ranking, so first we need to reverse the above sets, and then group the passing times of the results after the reverse order. Grouping will result in different times in different sets (otherwise, the same number of times in the same set). Then the specified collection and index after grouping are obtained through SelectMany. Finally, the final result ranking is obtained by projecting the collection. The code is as follows:
Var result = consults.OrderByDescending (d = > d.Times)
.GroupBy (d = > d.Times)
.SelectMany ((g, I) = > g.Select (e = > new Consult ())
{
Name = e.Name
Times = e.Times
Rank = I + 1
}). ToList ()
The above content is how to use C# statistical results to rank, have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.