Anonymous IComparer implementation

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

    The .NET framework version 4.5 provides the method Comparer.Create(Comparison) to create comparers based on a specified comparison delegate (which can be a lambda function). However people who are working with earlier versions of .NET will probably need to implement something similar themselves.

提交回复
热议问题