Up and coming features in C# 3.0

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
  • Lamda expressions
  • Object initializers
  • Collection initializers
  • Query expressions
  • Anonymous types
  • Expression trees
  • Automatic properties
       (Source: C# 3.0: Upcoming Language Features)

26.1Implicitly 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.

 

Download ( Overview of C# 3.0 )

Download ( Ocas October CTP - C# 3.0 Virtual PC Image

Watch ( C# 3.0: Future Directions in Language Innovation )


Posted Dec 30 2006, 12:34 PM by Blake Niemyjski |
windowscoding.com;
Copyright © 2008 Windows Coding
Microsoft and Microsoft logo's are trademarks of Microsoft Corporation.