Why not to allow in-place interface implementation in .NET?

Either I am missing something or .NET doesn't support what Java does. I'd like to be able to avoid creating a small class just for the sake of implementing a small interface. For example, LINQ's Except method expects IEqualityComparer. So I had to write a small class that implements the interface. However in Java I can simply do a new IEqualityComparer() { //interface declarations } and be done with it. So what's the problem?

This is somewhat related to this post:

Can a C# anonymous class implement an interface?.

ADDITION: На данный момент я добавил переопределения для Equals и GetHashCode .

13
задан FreakyAli 16 February 2018 в 13:58
поделиться