The Resharper cult members already know this, but for those who haven't joined yet, version 4.0 released today with VS 2008 support -- huzzah, huzzah. No longer able to resist the chanting and promises of eternal coolness I donned my robe and installed my free copy.
I clearly should have joined sooner. Resharper has already changed my life. First it pointed that I had redundant overrides in the control I was working on, which I had really meant to delete.
Then it reminded me about the new implicit type declaration keyword var, so this...
XmlDocument SomeDoc = new XmlDocument();
becomes...
var SomeDoc = new XmlDocument();
Granted, that's not too exciting, but if your type declaration is something like...
Dictionary<SomeStrangeType,ANamespace.AnotherLongType> SomeDictionary = new Dictionary<SomeStrangeType,ANamespace.AnotherLongType>();
with var it becomes...
var SomeDictionary = new Dictionary<SomeStrangeType,ANamespace.AnotherLongType>();
Then Resharper pointed out something I didn't realize was available in C#, the object intializer?? VB.NET has long had something similar with the With statement (now with object initializer goodness too). What's nice about this is that it saves repeating the instance name in front of the properties. So this...
var MenuBinding = new MenuItemBinding(); MenuBinding.DataMember = MenuItemElementName; MenuBinding.TextField = DisplayTextAttribute; MenuBinding.NavigateUrlField = NavigationUrlAttribute; MenuBinding.Depth = Depth;
var MenuBinding = new MenuItemBinding { DataMember = MenuItemElementName, TextField = DisplayTextAttribute, NavigateUrlField = NavigationUrlAttribute, Depth = Depth };
I was staring at this new construct when I realized that -- it shouldn't work. The project I was working on was a Framework 2.0 project and these things were in 3.0 syntax. But the darn thing compiles and works. Not even a single warning. WTF? It turns out that since 3.0 and 3.5 are based on 2.0, these are simply compiler tricks -- there is nothing fundamentally different about the types. Here's a blog post that explores in more detail what is happening under the covers.
Not bad for 15 minutes of tooling around. Guess I am an official member. Where's the Koolaid?
Remember Me
Theme design by Dean Fiala
Pick a theme: BlogXP calmBlue Candid Blue dasBlog Discreet Blog Blue Elegante essence Just Html Mono Movable Radio Blue Movable Radio Heat orangeCream Portal Project84 Slate Sound Waves Tricoleur windmill
Powered by: newtelligence dasBlog 2.1.8102.813
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2008, Dean Fiala
E-mail