March 2009 Entries

Take advantage of new C# 3.0 features (Part 2)

This is part two in my series about taking advantage of newer C# features.  These have been widely available since Visual Studio 2008, but you may not be using them yet.  In this post I’ll discuss object initialization. This feature is a time-saver.  Just a language enhancement.  It’s cool though.  Anything that makes the language more expressive is a good thing.  Typically, you create objects, then set the properties. Person p = new Person(); p.FirstName = “Arian”; p.LastName = “Kulp”; Now you can do it in just a single-line.  With the default constructor, you don’t even use parenthesis.  Just use curly...

Take advantage of new C# 3.0 features (Part 1)

I’ve decided to start a series of C# 3.0+ features that every dev should know about.  Probably I’m preaching to the choir (and I’m certainly not the only person mentioning these), but it’s easy to get used to features from   Automatic properties This is such a simple feature, but a nice one to know about.  Good object-oriented design demands that you never expose class fields directly.  Why not?  It’s all a matter of control!  Who wants to take a chance that other code might invalidate your values?  A name field set to null, or an...