Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at
.NET 2.0 (Almost) a Year Later

Well, according to Wikipedia the 2.0 RTM was released in November of last year (and we all know Wikipedia is always right... Except for last night when I went to the Jaguar page and the only text for the entire article was F**K YOU!).

Anyhow... My point is that the Framework saw some pretty big changes in the jump from 1.1 to 2.0, and I thought it would be fun to ask everybody that might be reading this to go through a little exercise of self reflection with me. Nothing "new-agey," I promise. I just want to know which of the new features that showed up in 2.0 are actually being used vs. the complete and utter duds (like themeing in ASP.NET).

My "being used" list:

  • Master Pages, which had to be manually hacked in with ASP.NET 1.1.
  • Generics, of course. This was a fantastic addition to the framework, and not just because they let you have strongly typed lists out of the box. Take a look at Jean-Paul Boodhoo's post on validation in the domain layer for some other practical uses of generics. (As an aside, I'll be linking to JP a lot on this blog. He's a bald, boyish ninja of practical articles).
  • The System.Collections.Generic.List class. I'm not talking about the generic stuff here, but rather the new methods like FindAll, FindLast, RemoveAll, TrueForAll, etc. These are super-wicked and often overlooked methods that will one day (when C# 3.0 comes out) lead to super-concise ruby-like code. In the meantime, they allow us to write code without foreach all over the place.
  • Anonymous delegates are a feature that, when combined with the generic List class, I find myself using more and more. We can currently (in 2.0) write code like this:
	myList.FindAll(delegate(User user) 
{ return user.Name == “Jorge”; };

I've probably missed a few things in this list. Now here's my "un-used" feature list:

  • Anything new in ASP.NET other than master pages. This includes themes, new controls, the new project-less model, and probably a few other things. As Sam Smoot put it ASP.NET is a Rube Goldberg Machine. I can't help but think that in the never-ending quest to make programming so simple even a monkey can do it, we've lost site of the forest for the trees.
  • Iterators are something I've never personally used yet.
  • Ditto partial classes. I've inadvertently used them in ASP.NET because that's the way code-behind now works (or is it code-beside?). This is something that is best used for code generation, but I've never consciously used the feature.

Once again, I'm sure this list is incomplete, so I'd like to hear what other's think. Speak!

Posted 09-24-2006 9:35 AM by Jeff Perrin
Filed under:



Bob Yexley wrote re: .NET 2.0 (Almost) a Year Later
on 09-24-2006 1:24 PM

I'll toss another one into the mix. I've personally become a HUGE fan of the null coalesce operator [0] introduced in C# 2.0. I used to LOVE the ternary operator, but now, the null coalesce operator does what I always *wanted* to be able to do with the ternary operator. VERY cool.


Jeff Perrin wrote re: .NET 2.0 (Almost) a Year Later
on 09-24-2006 1:57 PM

Thanks Bob.  I didn't even know that existed. It does remind me about nullable type support, which I've used to get DateTime -> Database stuff working with nHibernate. Forgot that one.

Rob Eisenberg wrote re: .NET 2.0 (Almost) a Year Later
on 09-24-2006 2:38 PM

The features I end up using the most are definately the ones you mentioned.  I have used iterators as well.  They are particularly useful if you have a tree structure and you need to iterate over all the nodes.  Using iterators, it is surprisingly easy to write this, and without using recursion either.  

For ASP.NET projects I have found myself using the new GridView most.  In the WinForms arena, the new layout panels are particularly useful and so is the BackgroundWorker.

There are lots of littel things that I love as well, such as string.IsNullOrEmpty and int.TryParse.

Bob wrote re: .NET 2.0 (Almost) a Year Later
on 09-24-2006 4:44 PM

In addition to Master Pages, I use the ASP.NET Membership and Role Management, SQL Output Caching Support, CSS Control Adapters, GridView control, and Menu system.  These save me dozens of hours a project.

Jeff Perrin wrote re: .NET 2.0 (Almost) a Year Later
on 09-24-2006 5:46 PM

Bob:  I'll admit that being able to just drop in the ASP.NET user/role stuff is alright, however the 2.0 Menu system and CSS control adapters are a fantastic example of what's wrong with ASP.NET. Here's the way I see it:

- Create a Menu control, that outputs html straight out of 1999.

- Realize that its output is complete crap.

- Create an entire project that must be downloaded just to fix what shouldn't have been broken to begin with.

It's almost comical, and is exactly what Sam was referring to when he called ASP.NET a Rube Goldberg machine. Why not just create a User Control that outputs proper semantic html to begin with, and then style it using proper CSS in the first place? Why do we instead create an XML file defining our menu structure, drop a Menu control on the page and *then* download the CSS control adapter project to generate proper markup? Absolute insanity.

Jeevan wrote re: .NET 2.0 (Almost) a Year Later
on 09-24-2006 5:47 PM

The Array class has several static methods that work similar to the List<T> class for arrays.

Derik Whittaker wrote re: .NET 2.0 (Almost) a Year Later
on 09-24-2006 6:07 PM

One of the new features i have enjoyed is Nullable types, but they did a really, really bad job of implementing them in the winforms UI stuff.

As for iterators, I have found a use for them, and they have made life easier for other developers on my team.

Bob wrote re: .NET 2.0 (Almost) a Year Later
on 09-24-2006 9:56 PM

Jeff - I actually prefer having flexible control adapters versus having HTML hard-coded into controls.  For our teams we've built serveral common class libraries that encapsulate output markup (using control adapters together with CSS stylesheets that we had a designer build for us), navigation layout that integrates with a CMS library we build, and security architecture.  

When we start a new project, we simply add references to these common libraries and we are pretty far on our way with the application.  Being able to encapsulate and test these separately and re-use them across multiple solutions is really useful for us.

Marcin Hoppe wrote re: .NET 2.0 (Almost) a Year Later
on 09-25-2006 4:17 AM

Apart from the most popular things that have already been mentioned (generics, nullable types, iterators, String.IsNullOrEmpty and TryParse family of methods) I have found new XmlReader features particularly useful. Methods like XmlReader.ReadContentAsInt make XML parsing a charm.

Matt Dunn wrote re: .NET 2.0 (Almost) a Year Later
on 09-25-2006 8:18 AM

Hi Jeff,

Heres my list of "being used" .NET 2.0 features:

- Tracing in System.Net

 System.Net libraries have been instrumented via Trace output.

- Automatic Proxy Detection

- ASP.NET 2.0 Deployment Mode

 If set in the machine.config file, instructs ASP.NET to disregard debug="true" etc settings in web.config files.


    <deployment retail=”true”/>


- Generation of Serialization Assemblies at Design Time

 XML Serializer Generator Tool (Sgen.exe)

- Version Tolerant Serialization between .NET 1.1/.NET 2.0

 Useful for upgrade strategy from .NET 1.1 to .NET 2.0.

- SynchronizationContexts

 Execute behaviour in the UI context

Whilst I don't have an immediate list of unused .NET 2.0 features, heres a list of behavioral changes to watch out for:

- try{}catch{} Behaves Differently for Unmanaged Exceptions

 Unamanaged exceptions are now wrapped in a RuntimeWrappedException instance.

- Non-UI Threads Raise Unhandled Exceptions by Default

 .NET 1.0/.NET 1.1 behaviour can be restored using the <legacyUnhandledExceptionPolicy> element:

- Assembly Loading Failures are Cached

 For a further explanation:

 .NET 1.0/.NET 1.1 behaviour can be restored using the <disableCachingBindingFailures> element:



Brendan Tompkins wrote re: .NET 2.0 (Almost) a Year Later
on 09-25-2006 9:16 AM


My used versus unused list is almost exactly like yours,  except for anonymous delegates (which I will use very soon) and I am using the web project model.

Oh, and Object Data Sources, I'm using these too along with the Grid View class.  Okay, now I'm starting to sound like one of the bloggers in my cartoon :)

The one thing I think you're hitting on is that while some of the stuff is very useful, some other stuff probably would have been better left out.

Jeff Perrin wrote re: .NET 2.0 (Almost) a Year Later
on 09-25-2006 9:26 AM

Brendan - Actually, that cartoon is what inspired the post!  I forgot to link back to it (doh).  

Brendan Tompkins wrote re: .NET 2.0 (Almost) a Year Later
on 09-25-2006 9:31 AM

Ha!  I just thought it was a zeitgeist thing.. Cool!

Brendan Tompkins wrote re: .NET 2.0 (Almost) a Year Later
on 09-25-2006 9:33 AM

Oh, and I couldn't agree more about just making controls render css-stylable markup. That's the real solution... just give us some stylable html, and we'll take it from there.

Christopher Bennage wrote re: .NET 2.0 (Almost) a Year Later
on 09-25-2006 11:02 AM

One small thing I discovered this weekend while working on some 1.1 code is that I like being able to declare a class static.

Another feature I've used is declaring different visibility on getters and setters.

David Longnecker wrote re: .NET 2.0 (Almost) a Year Later
on 09-25-2006 11:05 AM

Almost all of my 2005 experience, thus far, as been at polar ends--console apps for automation and AD tasks and web applications.

A note, I was a slow adopter of .NET and only used 1.1 for developing in CMS and SharePoint; 2.0 is my first real experience with enterprise application development and I'm glad I finally made the switch. ;)

My likes:

Master Pages, already mentioned.  The amount of time saved for things I was already doing with includes in the legacy ASP days.

Better exception handling using try/catch/finally as well as custom redirection via web.config for error types.

More acceptance from vendors.  Much of my database backend work is on Oracle; the new Oracle tools go a long ways from the ODBC tools in legacy ASP and 1.1.

Code snippets and the manager.  Most all of my common tasks now have their own snippets.

GridView & imageButtons.  These are the two new controls I tend to use the most.  The flexibility of Gridviews continue to amaze me on some projects--given the amount of time available to dink.

Things I don't use:

Themes.  Style sheets for everything.  I've messed around with theming a bit, but cannot see much use for it.  *shrug*

SiteMaps.  Why?  Modifying the XML file required for SiteMaps seems more of a hassle than creating a custom control and storing the information in a database table.

Other controls such as the Wizard, AdRotator, Menu, TreeView, SiteMapPath & Calendar.

Now, things I'd like to learn more about, but just haven't had time.

Authentication and Roles.  Almost everything I do is AD-integrated, so I rarely use Roles (using Group memberships in AD).  I hope to have time to sit down and learn the advantages of Role/form-based authentication in 2.0 as the controls look pretty straight-forward.

Jeff Perrin wrote re: .NET 2.0 (Almost) a Year Later
on 09-25-2006 11:17 AM

bennage - Ah, I forgot about differing visibilities on properties. They are definitely something I've been using quite a bit. I haven't used static classes yet.

Jim Bolla wrote re: .NET 2.0 (Almost) a Year Later
on 10-03-2006 7:57 PM

One of my favorite 2.0 features (besides generics) are iterators. Makes encapsulating data access calls super sweet...

public IEnumerable<Document> SearchDocuments()


using (SqlConnection connection = new SqlConnection(ConnectionString))

using (SqlCommand command = new SqlCommand(CommandText, connection))


command.Parameters.AddWithValue("@drawingNumber", drawingNumber);


using (SqlDataReader reader = command.ExecuteReader())

while (reader.Read())

yield return BuildResult(reader);



Results are streamed and all the IDisposable objects get cleaned up nicely. BuildResult converts an IDataRecord into a DTO. Calling code has no clue about databases. Sweet.

rsymonds wrote re: .NET 2.0 (Almost) a Year Later
on 10-12-2006 4:46 PM


Could you elaborate a little on the code in the post above and maybe provide some skeleton code for BuildResult(). This is an interesting approach that I'm not familiar with. Thanks.

mikemalter wrote re: .NET 2.0 (Almost) a Year Later
on 10-14-2006 12:04 PM


I'd like to see some code too.  Thanks.

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Google Reader or Homepage Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of
Red-Gate Tools For SQL and .NET


SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
NHibernate Profiler
Balsamiq Mockups
JetBrains - ReSharper
Web Sequence Diagrams
Ducksboard<-- NEW Friend!


Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers


Community Server (Commercial Edition)