Anonymous IComparer implementation

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

    No, this is not possible. However, you can get the default implementation of IComparer by Comparer.Default. Otherwise you'll need to create a parameterized implementation and use an instance of that.

提交回复
热议问题