IComparable<T>
may be particularly useful CS-R1106The specified class has a method whose signature resembles IComparable<T>::CompareTo(T? other)
but does not implement IComparable<T>
. If your method indeed performs a comparison between 2 objects of the same type, it may be particularly useful to implement the IComparable<T>
interface which is defined exactly for purposes like these.
class C
{
public int CompareTo(C? other)
{
// ...
}
}
class C : IComparable<C>
{
public int CompareTo(C? other)
{
// ...
}
}