Geeks With Blogs
Blog Moved to http://podwysocki.codebetter.com/ Blog Moved to http://podwysocki.codebetter.com/
Since I like to stay ahead of the curve when it comes to new technologies, I came across the C# 3.0 specification recently and thought it was quite interesting.  I obtained the overall specification from Microsoft as a word document here:  http://download.microsoft.com/download/9/5/0/9503e33e-fde6-4aed-b5d0-ffe749822f1b/csharp%203.0%20specification.doc
 
Anders Heljsberg gave a presentation about the new specification on the MSDN Channel 9 which can be found here:  http://channel9.msdn.com/ShowPost.aspx?PostID=10276
 
First off, C# 3.0 looks like it brought some of the lessons learned from C-Omega and F#.  Let's take a look at the new language features one by one in the coming weeks.
 
The first feature is the implicitly typed local variables.  To me, this looks much like Javascript in terms of its overall look and feel, but has inherent differences.  You can declare any local variable implicitly by using the var keyword and you must assign a value at initialization or else it will not work.  Here are some examples
 
var localInt = 2;  // Same as int localInt = 2;
 
Here are some examples that will not work:
var localString; // Not initialized
var nullObject = null; // Null not permitted
 
Why you may ask that they included this.  I have thought this myself a couple of times and see this not much more than syntactical sugar.  Any thoughts?
 
Posted on Friday, May 12, 2006 2:56 PM Microsoft , .NET , C# | Back to top


Comments on this post: C# 3.0, First Thoughts

# re: C# 3.0, First Thoughts
Requesting Gravatar...
Where this is really, really powerful is with returning custom shaped objects from LINQ queries. Since the typing can be inferred, you get intellisense and compile-time checking using the var keyword when you are returning LINQ queries. This allows you to easily access the results in a strongly typed way without having to declare an object type.

Hope this helps,

Scott
Left by scottgu on May 12, 2006 7:19 PM

Your comment:
 (will show your gravatar)


Copyright © Matthew Podwysocki | Powered by: GeeksWithBlogs.net