日期:2014-05-17 浏览次数:20947 次
class Student { public int ID { get; set; } public string Name { get; set; } public int Score { get; set; } } void Main() { List<Student> students = new List<Student>(); for (int i = 1; i <= 4; i++) { Console.WriteLine("Please input the student name:"); string name = Console.ReadLine(); Console.WriteLine("Please input {0}'s ID:", Name); int id = int.Parse(Console.ReadLine()); Console.WriteLine("Please input {0}'s Score:", Name); int score = int.Parse(Console.ReadLine()); students.Add(new Student() { Name = name, ID = id, Score = score }); } foreach (Student student in students.OrderByDescending(x => x.Score)) { Console.WriteLine(student.Name); } }