using System.Collections.Generic;
public static void Main()
List<Person> personList = new List<Person>();
personList.Add(new Person { Age = 10, Name = "John" });
personList.Add(new Person { Age = 15, Name = "Ann" });
personList.Add(new Person { Age = 8, Name = "Kevin" });
foreach (var item in personList)
Console.WriteLine(item.Name + ":" + item.Age);
public class Person : IComparable<Person>
public int Age { get; set; }
public string Name { get; set; }
public int CompareTo(Person other)
return this.Age.CompareTo(other.Age);