更新时间:2023-12-03 17:14:52
使用LINQ:
using System.Linq;
var ranked = playerScores.Select((score, index) =>
new {Player=index+1, Score=score})
.OrderByDescending(pair => pair.Score)
.ToList();
然后显示获胜者,例如:
And then display the winner, for example:
Console.WriteLine(String.Format("Winner: Player {0} with score {1}",
ranked[0].Player, ranked[0].Score));