Is the C# 2.0 to C# 3.0 transition worth it for this project? [closed]

我们两清 提交于 2019-11-29 11:22:33

问题


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.


回答1:


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.




回答2:


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 with 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.




回答3:


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.




回答4:


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.




回答5:


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!




回答6:


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.




回答7:


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.




回答8:


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.




回答9:


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.




回答10:


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.



回答11:


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.




回答12:


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




回答13:


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




回答14:


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.)




回答15:


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.




回答16:


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.



来源:https://stackoverflow.com/questions/170584/is-the-c-sharp-2-0-to-c-sharp-3-0-transition-worth-it-for-this-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!