C# 1.0 was the core about OO, C# 2.0 added generics. With C# 3.0 is the first version with new language features - LINQ, and this is expands with the future versions. C# is a multi-paradigm language. Of course, it's an OO language (since 1.0), since 3.0 it can also be used as functional language. The main areas of enhancements are in these areas:
Microsoft is doing a shift in regard to C# and VB to recognize reality. Features from C# are brought into VB, and features from VB into C# - because the demand is here!
The enhancements can be grouped into these areas:
- dynamic keyword
- optional and named parameters
- co- and contra variance
Using C# it is also possible to create dynamic runtime-objects by implementing the interface IDynamicObject or deriving from the base class DynamicObject.
A many times requested feature that is available with C# 4.0 is optional and named parameters. Instead of defining several overloads, optional parameters can be defined:
StreamReader OpenTextFile( string path, Encoding encoding = null, bool detectEncoding = true, int bufferSize = 1024);this can be called wih only the mandatory parameter:
OpenTextFile("foo.txt");and also with named arguments:
OpenTextfile("foo.txt", bufferSize : 4096);Of course, named arguments must be after the mandatory parameters.
Optional and named parameters have a great COM Interop story. No more ref missing parameters. "It took 10 years to get back where we were".
Covariance and contra-variance is another new feature. co-variance or contra-variance information can be added to generics, e.g. and . means that T can be used only in output positions, only in input positions. Existing interfaces and delegates such as IEnumerably and IComparable are changed to the new notation. A blog entry with samples about this feature follows here!
Anders also demonstrated C# 5.0 features. C# 5.0 opens up the compiler to offer modern ways for meta-programming - compiler as a service!
More information about C# futures:http://code.msdn.microsoft.com/csharpfuture