Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why should I upgrade to c# 4.0?

Tags:

c#

c#-4.0

I know there are some nice new features in C# 4.0 but I can't, for the life of me, think of a compelling reason for either upgrading existing projects or for switching to new projects.

I've seen some posts where people have said that if their hosting service didn't provide .Net 4 that they'd find another provider as .Net 4 was pinicle to their direction <?>.

Now my boss is trying to get me to agree to switch all our production environments to C# 4 and to do it now.

So the question is has anyone either began using, or converted a project to, C# 4 for a compelling reason? Was there a feature that you just had to have that would make your life so much easier?

like image 473
griegs Avatar asked Jul 15 '10 22:07

griegs


3 Answers

There are some cool new features in C# 4.0:

  • Dynamic member lookup
  • Covariant and contravariant generic type parameters
  • Optional ref Keyword when using COM
  • Optional parameters and named arguments
  • Indexed properties

In his release blog post Scott Guthrie goes into detail about the features of .NET 4 in general. Another great resource is a white paper at http://www.asp.net/learn/whitepapers/aspnet4. However, I'd doubt you are going to need one / any of these new features right away. As Scott Hanselman blogged:

there's a lot of stuff that's new and added in .NET 4, but not in that "overwhelming-I-need-to-relearn-everything" way.

Whether or not you should upgrade is therefore dependent on a variety of other factors. Some reasons that spring to mind:

  • Standardizing your development environment on a single platform VS2010 over VS2008.
  • Size of the .NET Framework is substantially reduced
  • Speed improvements if you are a Visual Studio Tools for Office developer

An open dialogue with your manager seems appropriate to understand his reasoning for the upgrade. I'd argue that because it's shiny isn't a compelling reason.

As a reference this dated Stack Overflow question "Why not upgrade to the latest .net framework" provides the inverse to your question.

like image 169
ahsteele Avatar answered Oct 26 '22 05:10

ahsteele


  • Quite frankly System.Collections.Concurrent has made developing multi-threaded applications a breeze.

  • The new and improved System.Linq.Expressions makes writing dynamically compiled code seem like child's play.

  • The new named parameters feature means I can have big constructors and not get confused as to what each parameter is. Immutable objects are just that much easier.

like image 37
ChaosPandion Avatar answered Oct 26 '22 06:10

ChaosPandion


Surprisingly not mentioned:

  • PLINQ
  • Task Parallel Library
like image 42
Marc Bollinger Avatar answered Oct 26 '22 05:10

Marc Bollinger