In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.