EqualityComparer<T>.Default isn't clever enough
问题 I was reading the source code of EqualityComparer<T>.Default and found that it's not so clever. Here is an example: enum MyEnum : int { A, B } EqualityComparer<MyEnum>.Default.Equals(MyEnum.A, MyEnum.B) //is as fast as EqualityComparer<int>.Default.Equals(0, 1) enum AnotherEnum : long { A = 1L, B = 2L } //is 8x slower than EqualityComparer<long>.Default.Equals(1L, 2L) The reason is obvious from the source code of the private method in EqualityComparer. private static EqualityComparer<T>