static void Main(string[] args) { Rechthoek[] Feguren = new Rechthoek[10]; Feguren[0] = new Rechthoek(2, 9); Feguren[1] = new Rechthoek(2, 7); Feguren[2] = new Rechthoek(2, 5); Feguren[3] = new Rechthoek(2, 10); Feguren[4] = new Rechthoek(2, 6); Feguren[5] = new Rechthoek(2, 2); Feguren[6] = new Rechthoek(2, 8); Feguren[7] = new Rechthoek(2, 4); Feguren[8] = new Rechthoek(2, 3); Feguren[9] = new Rechthoek(2, 1); foreach (var item in Feguren) { Console.WriteLine(item.ToonOppervlakte()); } Console.WriteLine("-------------"); Array.Sort(Feguren); foreach (var item in Feguren) { Console.WriteLine(item.ToonOppervlakte()); } Console.ReadLine(); }
public int CompareTo(object obj) { Rechthoek temp = obj as Rechthoek; return(ToonOppervlakte().CompareTo(temp.ToonOppervlakte())); }