Should we extend Comparer<T> or implement IComparer<T>
问题 What is the best practice in C# starting from version 4.0 when writing a comparer class : a. Should we inherit from Comparer abstract class ? or b. Should we implement IComparer interface. What are the pros and cons? 回答1: I would recommend that you extend the Comparer<T> class instead of implementing the IComparer<T> interface, as does Microsoft (see first reference below). Now, if you want your object itself (whatever T is) to be able to compare against itself, it can implement the