I’m personally looking forward to C# 3.0. There are some interesting new things coming to the language. However there are somethings I really don’t like about c# (please pay attention to the end of this video Anders Hejlsberg - Programming data in C# 3.0)
- Local variable type inference (I personally don’t really like this idea)
- Extension Methods
- Lambda expressions
- Object initializers
- Collection initializers
- Query expressions
- Anonymous types
- Expression trees
- Automatic properties
Source: C# 3.0: Upcoming Language Features - Nick Wong
26.1 Implicitly typed local variables
In an implicitly typed local variable declaration, the type of the local variable being declared is inferred from the expression used to initialize the variable. When a local variable declaration specifies var as the type and no type named var is in scope, the declaration is an implicitly typed local variable declaration. For example:
var i = 5; var s = "Hello"; var d = 1.0; var numbers = new int[] {1, 2, 3}; var orders = new Dictionary<int,Order>(); The implicitly typed local variable declarations above are precisely equivalent to the following explicitly typed declarations: int i = 5; string s = "Hello"; double d = 1.0; int[] numbers = new int[] {1, 2, 3}; Dictionary<int,Order> orders = new Dictionary<int,Order>();
This reminds me of javascript, and personally I think this is a wrong move for the language because it kind of forces developers to be lazy. Even more so on larger projects could lead to developers that are maintaining code to do extra work just to understand the code. We will just have to wait and see how it turns out.
Share this post
Twitter
Facebook
Reddit
LinkedIn
Email