Okay so I have a scenario similar to the below code, I have a parent class that implements IComparable and a child class.
class Parent : IComparable<Parent>
class Child : Parent
Child a = new Child();
Child b = new Child();
a.CompareTo(b);
Now the above works fine, i can compare two of the child objects to each other no problem
List<Child> l = new List<Child>();
l.Add(b);
l.Add(a);
l.Sort();
The above fails though with an InvalidOperationException. Can someone please explain why this sort isn't working when the child class does implement the IComparable interface, or at least it seems to me that it does.
Okay here is my CompareTo implementation for my actual parent class
public int CompareTo(IDType other)
{
return this.Name.ToString().CompareTo(other.ToString());
}