The Future of C# (4.0) is awesome

I just attended Anders’ session on what is new in C# 4.0, and I must say, I went in a critic, and came out an enthusiast. Big theme is to be more like VB.NET, such as optional and named parameters, and dynamic invocation of methods.

There are 4 new things in C# 4.0.

Dynamic language features
Optional and named parameters
Better COM-interop


Dynamic language features

C# will now have a new keyword called dynamic. With it you can declare a variable, which comes down to the same type as object, but now with dynamic syntax. In C# 3.0 if you have an object reference you need to use reflection to call methods, with C#4.0 you can call any method you know exists on the object.

This is great when using for example Silverlight, because now you can call Javascript code from C# with normal syntax, instead of having to use Invoke. Awesome!!!

Optional and named parameters

Now methods can have optional and named parameters (like VB.NET). Not much to say about that, except for the next bit.


Talking to COM objects have always been painful. C# 4.0 should make that a lot easier with dynamic invocatioons and optional parameters.


You can assign an object reference a string object, but you cannot assign reference to a collections of objects a collection of strings. With C# we can now specify whether or not we’ll allow this. So some of the collections and interfaces will now use this syntax and enable some legal scenario’s which are not permitted in C# 3.0.