Anonymous IComparer implementation

前端 未结 8 962
一整个雨季
一整个雨季 2021-02-03 17:57

Is it possible to define an anonymous implementation of IComparer?

I believe Java allows anonymous classes to be defined inline - does C#?

Looking at this code I

8条回答
  •  后悔当初
    2021-02-03 18:13

    Take a look at these 2 SO questions, they tackle essentially the same problem

    Use of Distinct with list of Custom Object

    Wrap a delegate in an IEqualityComparer

    If you go this way, you should pay special attention to Slaks' comments and Dan Tao's answer about the hashcode implementation

提交回复
热议问题