views:

1905

answers:

16

I have read on Stack Overflow some people that have converting to C#2.0 to C#3, but is it really worth it?

I have a project that is done at 75% before going in maintenance phase. I am asking to myself if it is worth it to switch to C#3.0?

Update:

The project will have a web interface now so before entering the maintenance phase we have to develop the web part (all was done for internal purposes with Windows Forms). Most parts will be resused (back-end). Most people have said that it wasn't worth it in the past because it was already at 75%... but now do you still think it's not worth it?

What have been done finally

Finally since we are continuing the project with the web interface we will update to 3.5 for the new year. Thank you everybody for all your input.

+12  A: 

Is there any C# 3.5 feature you want badly at this stage? :)

If it is LINQ, you can give LINQBridge a try.. With Studio's multi-targeting and LINQBridge, you'll be able to write local (LINQ to Objects) queries using the full power of the C# 3.0 compiler—and yet your programs will require only Framework 2.0.

Gulzar
I'd manually back-ported some of the methods myself. Thanks for the heads up about linqbridge. The less code I have to maintain, the better!
Orion Edwards
+22  A: 

No, I would advise not. I would advise starting 3.5 on new projects only, unless there is a specific reason otherwise. You will not have any benefit from 3.5 by just recompiling, since your code is already written (or at least 75% of it).

If you need to migrate to 3.5 in the future, you can easily do it. Of course, you will have code in 2.0 style, but what is done is done.

  • Be conservative, don't do something unless you need it.
  • An application which is 75% in C#2.0 and 25% in C#3.0 is not exactly a nice beast to maintain. A 100% C#2.0 application is certainly more maintainable.

When you are going to start a new project, then by all means switch! The new framework version is very interesting and the switch is hotly recommended.

Sklivvz
I disagree. Do you have specific (even anecdotal) evidence to support your otherwise subjective advice? Why limit yourself for no reason, or do you assume Daok is coding by coincidence and doesn't unit test? If it's so easily done, why wait?
Robert Paulson
I think the confusion comes from mixing .NET versions with C# versions.
Jeff Yates
Nop, I was talking about the framework version. Using C# with .Net 2 and was asking if it was good idea to change to C# with .Net 3.5...
Daok
While I haven't had any issues upgrading projects, I can appreciate how awkward the code base might be if 25% had v3.5 things things and the other 75% didn't.
Josh Bush
+2  A: 

If your project is nearly complete, you will probably not benefit from the new features of 3.5. For new projects, it is certainly worth a look.

BlackWasp
+6  A: 

I think a lot of this will come down to your personal style. IMHO, the best features of C# 3.5 really come down to the following

  1. Lambda Expressions
  2. LINQ
  3. Extension Methods

My OO code still tends to look a bit functional oriented. Therefore I see 3.5 as a huge benefit and it's definately worth the upgrade.

What's even better is it's possible to use the 3.5 compiler to down target CLR 2.0. This allows you to deploy based on a 2.0 install (vs a 3.0/3.5 install) using the new framework. All of the above can be done in this scenario if you're willing to add the appropriate types into your program.

JaredPar
+2  A: 

It really depends on the project, who it's intended for, and what it does.

It would be safe to guess that the .NET Framework 2.0 is on many more computers than version 3.5.

Additionally, is there anything you need from .NET 3.5 that isn't available in 2.0 (such as LINQ)? If you are dealing with a lot of queries and data, I would switch. But again, depends on the customer and if you intended to maintain this application for the foreseeable future.

JTA
+1  A: 

3.5 builds on top of 2.0, so you have no issues jumping directly to 3.5.

Darren Kopp
+50  A: 

Clarification
C# 3.5 doesn't exist. There is C#1.0, C#2.0 and C#3.0.

Then there is .NET 1.0, .NET 1.1, .NET 2.0, .NET 3.0, and .NET 3.5.

We should not confuse the two.

C# 3.0 vs C#2.0
Now, is C#3.0 worth the move? I would say that the existence of Extension methods and Lambda expressions, the answer is yes. These two features alone make for easier to read and quicker to write code. Add that to auto-implemented properties, LINQ, and partial methods, and C#3.0 shows itself to be an advantageous move.

However, it is not necessarily beneficial to move an existing project. You have to weigh the pros and the cons, especially with regards to introducing new bugs and instability, before deciding to migrate existing work. For new projects, I'd say start with C#3.0.

Jeff Yates
Damn... you beat me by 18 seconds.....
James Curran
Wow, get out of my head!
Jeff Yates
.NET 2.0 is the runtime for everything 2.0 and above. The only con to moving to 3.5 to get C#3.0 features is the time it takes to flip the drop down in Project Properties. Seriously takes all of 10 seconds per project...
sliderhouserules
@sliderhouserules: That's not true. The CLR in .NET 2.0 is used in frameworks 2.0 and above. The framework and the CLR are not the same thing.
Jeff Yates
+1  A: 

I would... there's no harm and you get some benefits from the new features

sebastian
+3  A: 

In my opinion, there's no good reason not to switch to 3.5.

The real killer feature is that you can continue to target older versions of the runtime (2.0+) while using all the new language features. So you can use the new lambda expressions, extension methods, anonymous types, and all the other good stuff. And if your customers are still primarily using the 2.0 framework, you can continue targeting the earlier runtime.

(Just don't use any of the classes from the 3.5 framework, if you have to target earlier runtime versions.)

Personally, I think if you're doing a desktop GUI app, your best bet is to use the 3.0 or 3.5 framework, since WPF is the best user interface library I've ever worked with (by a long shot).

On the other hand, if you've already written most of your GUI in WinForms, then you might be interested in the 3.5 framework, which allows (limited) intermingling of WinForms and WPF GUI elements. You can keep the work you've already done, but add a few nice touches here and there, wherever it makes sense, with WPF controls.

Another handy feature of the 3.5 framework is "Collection Initializers". Check this out:

var myDictionary = new Dictionary<String, String> {
   { "key-1", "value-1" },
   { "key-2", "value-2" },
   { "key-3", "value-3" },
};

Neat, huh?

I'd have liked it a little better if it was a little more JSON-like. But it's very convenient functionality anyhow.

Any you can event target that code for the 2.0 runtime!

benjismith
+2  A: 

From a technology standpoint, it's all framework version 2 and it's very little effort to achieve. The differences in 2.0, 3.0 and 3.5 are just additional library code and some compiler syntactic sugar.

It's not like you need to change anything over; by targeting framework 3.5 you have more options.

From your teams point of view: Yes it's worth it. Nobody wants to work on old code-bases. While you're in the heat of development, you might as well utilize the most current stable technology.

Robert Paulson
+2  A: 

It really depends on what you need to do. If your project requires Lambda Expressions where you're query objects with a clear syntax, you should look at 3.0.

I am currently reading C# In Depth by Jon Skeet, and he takes the approach of laying out a solution in C# 1.15, then evolves the solution to depict the new and useful functionality that you get in 2.0 and 3.0. This type of progression would be a perfect means to answer your questions. The book reads well too so I am finding I am getting through it quickly.

David Robbins
great book BTW. Well worth a read.
Harpua
A: 

I wouldn't change anything unless you have a good reason to do so; i.e. there is a bug that you can't work-around in 2.0.

Upgrading the framework at such a late point in the project is likely to cause some problems which you really don't need at the moment.

Gordon Carpenter-Thompson
+2  A: 

You have to weigh cost versus benefit. You don't provide enough information about your project to allow us to advice you here, but consider:

  • cost of conversion is pretty small. C# 3.0 is almost completely backwardly compatible with 2.0 and run on framework 2.0
  • benefit is also pretty small if the coding is almost finished, but might grow in the long run. A new feature you might have to implement in the future might turn out to be much easier implemented using Linq, for example.
JacquesB
+1  A: 

I don't understand all you people saying don't do it. .NET 2.0 is the current (CLR) runtime. .NET 3.0 and .NET 3.5 both run on the 2.0 runtime. Moving to .NET 3.5 to get the C# 3.0 features is literally a matter of changing a single dropdown in your project properties. (OK, and deploying the 3.5 runtime to your target machines if you use some 3.5 features such as LINQ, etc. If installing 3.5 is an issue then it's not such an easy answer.)

sliderhouserules
+2  A: 

I've made the conversion many times. Mostly because the clear syntax from lambda expressions makes the code easier to follow (for me anyway).

I do use ReSharper which makes using new 3.5 features a snap as quite a few show up as refactoring suggestions by ReSharper. Using a tool like that makes this transition so much easier.

Harpua
A: 

If you have an extension to the project, it might be a good thing to switch now to the newest version of .NET, otherwise I wouldn't.

Pokus