There are lots of things I'd like to add or fix in C# and which I think would be easy to add/fix. I think that's a different question though.
As for things that seem to be permanently wrong, or at least would be very hard for MS to fix now, there aren't many. Let's see...
Loop Variables and Lambdas - The loop variable in foreach should be captured as a copied value by anon-funcs/lambdas inside the loop statement/block. Instead it is treated as if it was declared outside the loop, which is not what you want in 99% of situations, leading to the well-known lambda-foreach bug as documented on a thousand blogs.
No Free Functions - It should be possible to declare a function in a namespace (called a free function in C++). Instead we are required to declare them as static class members. In practice this means that we are forced to put a . in the middle of our free function names. This is required by the CLS, but I think it's a rather outdated idea.
struct - I originally thought this was a superb improvement over Java, user-definable compound value types, because as a C++ user I was prejudiced against the idea of having to allocate everything from the GC heap. But in practice they are terrible things with inconsistent and surprising behaviour, and the GC heap performs brilliantly anyway. Structs would have been better if they were required to be immutable. Also there should be a way to make the default constructor private so that the compiler will stop you from using the struct in any context where the default constructor might be called, e.g. in an array.
void - if I have a function void Foo()
why can't I say return Foo()
? Should be fine from another void
function. If this were so, we wouldn't need Action
, just Func<void>
. As we find more uses for functional style, the more we will encounter these situations where we have to write the same generic type twice with different names, to deal with this unnecessary asymmetry in the type system.
I also think when dynamic is added in version 4, that will be a largely unnecessary blot on an otherwise very carefully defined and evolved language. Maybe I'll feel differently when I try to use it, but I seriously doubt it.