Junior OOP

What is the IComparable interface?

  • Provides a standard method to compare objects for sorting.

class Employee : IComparable<Employee>

public int Id { get; set; }

public int CompareTo(Employee other) =>

this.Id.CompareTo(other.Id);

More from C# Programming Tutorial

All questions for this course