class Program { static void Main(string[] args) { string surname; int score; int numRecords = 0; Console.WriteLine("How many students?"); if (int.TryParse(Console.ReadLine(), out numRecords)) { List<Student> lstStudent = new List<Student>(); for (var i = 1; i <= numRecords; i++) { Student student = new Student(); Console.WriteLine(); Console.Write("Enter Name:"); student.Name = Console.ReadLine(); Console.Write("Enter Surname:"); student.SurName = Console.ReadLine(); Console.Write("Enter Score:"); student.Score = int.Parse(Console.ReadLine()); lstStudent.Add(student); Console.WriteLine(); } lstStudent = (List<Student>)lstStudent.OrderByDescending(x => x.Score).ToList(); for (int i = 0; i < lstStudent.Count; i++) { Console.WriteLine("{1},{2},{3}", (i + 1).ToString(), lstStudent[i].Name, lstStudent[i].SurName, lstStudent[i].Score.ToString()); } } Console.ReadLine(); } } public class Student { public string Name { get; set; } public string SurName { get; set; } public Int32 Score { get; set; } } }
MAX
TOP
ORDER BY
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)