Hacker News new | past | comments | ask | show | jobs | submit login

> What are the features that c# is missing? As the other comment explained delegates are the equivalent of anonymous inner classes and are far better.

Not entirely. .NET delegates don't support generic type parameters (aka first-class polymorphism). Methods in C# and Java do.

C# interfaces also don't support static methods, which are useful for factory patterns. C#'s factory patterns require a lot more code as a result.

C# also has a bunch of artificial limitations, like not being able to specify type constraints on Delegate, Enum, and a few other built-in types. It's just nonsense.

The rest of C# is overall better than Java though.




Not sure what you mean by "delegates can't accept generic type parameters" because you can certainly make a delegate with a <T> in it in C#


There is no delegate equivalent of passing around an instance of IFoo:

    interface IFoo
    {
        void Bar<T>();
    }
This is known as first-class polymorphism.

Classes with methods are strictly more powerful than delegates, but they shouldn't be. It's even worse than that actually, because you can't even create an open instance delegate to a generic interface or abstract class method (you'll get a runtime error, not even a static error).




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: