2
0

IComparable.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. // See the LICENSE file in the project root for more information.
  4. namespace System
  5. {
  6. // The IComparable interface is implemented by classes that support an
  7. // ordering of instances of the class. The ordering represented by
  8. // IComparable can be used to sort arrays and collections of objects
  9. // that implement the interface.
  10. //
  11. public interface IComparable
  12. {
  13. // Interface does not need to be marked with the serializable attribute
  14. // Compares this object to another object, returning an integer that
  15. // indicates the relationship. An implementation of this method must return
  16. // a value less than zero if this is less than object, zero
  17. // if this is equal to object, or a value greater than zero
  18. // if this is greater than object.
  19. //
  20. int CompareTo(object obj);
  21. }
  22. // Generic version of IComparable.
  23. public interface IComparable<in T>
  24. {
  25. // Interface does not need to be marked with the serializable attribute
  26. // Compares this object to another object, returning an integer that
  27. // indicates the relationship. An implementation of this method must return
  28. // a value less than zero if this is less than object, zero
  29. // if this is equal to object, or a value greater than zero
  30. // if this is greater than object.
  31. //
  32. int CompareTo(T other);
  33. }
  34. }