What problem does IStructuralEquatable and IStructuralComparable solve?

All types in .NET support the Object.Equals() method which, by default, compares two types for reference equality. However, sometimes, it also desirable to be able to compare two types for structural equality. The best example of this is arrays, which with .NET 4 now implement the IStructuralEquatable interface. This makes it possible to distinguish whether … Read more

How to Implement IComparable interface?

You should not define IComparable yourself. It is already defined. Rather, you need to implement IComparable on your BankAccount class. Where you defined the class BankAccount, make sure it implements the IComparable interface. Then write BankAccount.CompareTo to compare the balance amounts of the two objects. public class BankAccount : IComparable<BankAccount> { […] public int CompareTo(BankAccount … Read more