Lecture overview -- Keyboard shortcut: 'u'  Previous page: Interfaces from the C# Libraries -- Keyboard shortcut: 'p'  Next page: Sample use of IEnumerator and IEnumerable -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home  Page 15 : 37
Object-oriented Programming in C#
Abstract classes, Interfaces, and Patterns
Sample use of IComparable

Object of classes that implement IComparable can be sorted by a method such as Array.Sort

/user/normark/oop-csharp-1/sources/c-sharp/interfaces/reproductions/IComparable-non-generic.csA reproduction of the interface IComparable.


 

  • x.CompareTo(y)

    • Negative: x is less than y

    • Zero: x is equal to y

    • Positive: x is greater than y

Go to exerciseComparable Dice