Anonymous IComparer implementation

前端 未结 8 1056
一整个雨季
一整个雨季 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:14

    No, C# does not currently allow inline interface implementations; although it does allow you to create delegates inline through lambda expressions and anonymous methods.

    In your case, I would suggest using a ProjectionComparer that makes it easy to use this feature, such as the one listed here.

提交回复
热议问题