问题
I am into new desktop app development. I feel at home with .NET 2.0 and c#. I guess I don't need linq, nor care for WPF and other Vista-oid fancy keywords. I also like rather tight and slim 2.0 redistributable, even more for reason it's Vista and 7 included.
Why switch to 3.5?
回答1:
One word:
Linq
Once you've done a single query on your objects using Linq you'll never go back. Linq isn't just databases, you can have any kind of collection, and if you can express yourself functionally, you can change
foreach (obj in myCollection)
{
if (obj.property == match)
{
foundObj = obj;
break;
}
}
to
myCollection.Single(obj => obj.property == match);
EDIT: OR
var foundobj =
(from obj in myCollection
where obj.property == match)
.Single()
Which one makes more sense? What about when you want to express much more complex queries like where this and that and that, from that select the ones that match some other property. You can do it in two function calls.
Sorry about the rant but I really do like Linq.
回答2:
Assumption: You're working with Visual Studio 2005 and .NET 2.0.
Reason #1: Vista includes .NET 3.0 as a part of the OS Install; Windows 7 includes .NET 3.5
Reason #2: There are ways to target .NET 2.0 using Visual Studio 2008 (and VS 2010) so you can gain from the productivity "goodies" of those tools without abandoning .NET 2.0, then move to .NET 2+ when you're ready. (Visual Studio can help you avoid non .NET 2.0 assemblies while you code.)
Reason #3: Extension methods, particularly the static class Enumerable
. Technically, a part of Linq, but a good way to write code cleanly, clearly, and in a more maintainable way.
Reason #4: Bug fixes to the .NET 2.0 framework. Remember that .NET 3.0 and .NET 3.5 still use the same .NET 2.0 runtime under the hood - they just add new frameworks/libraries and some compiler tricks. There have been a ton of bug fixes to the runtime which you're missing out on.
回答3:
One reason not to use 3.5 is Mono.
The Mono API today is somewhere in between .NET 2.0 and .NET 3.5 see our Roadmap for details about what is implemented.
Taken from here.
Another reason is that Winforms hasn't moved forward hardly at all, so you may want to wait until 4.whatever comes out before jumping.
My understanding is that some stuff, like LINQ, can be used just fine with .Net 2.0, since it's just a Library.
回答4:
Moving from .NET 2.0 to .NET 3.5 shouldn't even be a consideration. Here are some reasons why.
- .NET 3.5 is fully backwards compatible with .NET 2.0 as it is built on the same core. 3.0 and 3.5 are merely extensions to 2.0.
- LINQ - You can use Linq even without using databases. It changes every thing. This feature alone is well worth the move.
- Lambda Expressions - Powerful search capabilities within collection. Related to LINQ.
- Anonymous Methods - Created mthods without fully defining them.
- Anonymous Types
- Windows Workflow Foundation - Create workflows.
- Windows Presentation Foundation - Replaces legacy Windows Forms - Can still be used with existing WinForms though.
- Silverlight - Scaled back version of WPF for Web-Facing applications. Analagous to Flash.
- Windows Communication Foundation - Replaces traditional Remoting and Web Services pieces with a much more robust infrastructure
- For Web Development - ASP.NET MVC Framework - BEST!!!!
Without .NET 3.5, you're missing out on a lot. Seriously. Make the jump. You'll be glad you did.
回答5:
If you don't need LINQ, don't want WPF (or WCF), and don't like the extended use of generics, the simple answer is: don't do it!
However once you have used just one of the above features of 3.5 you will wonder how you ever did without. The real reason to move to 3.5 is to get the benefit of these features.
So if you are completely happy with 2.0, and have never said "I wish I could just... xyz", I suggest you stay where you are.
回答6:
C# 3.0 has some really nice features, such as automatic properties and collection initialisers - both of which really clean your code. Linq is also great when dealing with collections, Lambda expressions are also cool.
.NET 3.5 is also included within Windows 7.
Question is - Why not?
回答7:
I would upgrade just for lambdas!
SaveButton.Click += new EventHandler((sender, e) => this.Save());
回答8:
If you don;t need to use any of the 3.5 features, then don't worry, it is just an addition of new Framework Libraries, the CLR and CLI havn't changed, thus everything you write, be it using framework libraries from version 2.0, 3.0 or 3.5 all ends up as the same IL code. Knowing this, if at some point in the future you decide you do want to add some 3.5 functionality to you application, you can do so with the knowledge that there will be no migration pains (ike the upgrade from 1.1 to 2.0) as all you're really doing is telling Visual Studio to "let you add the 3.0/3.5 dlls" to your project. Of course you will have to make sure your users have .net 3.0/3.5 installed.
回答9:
I know various people who feel right at home with C, 8086 assembly, APL, punchcards, and front toggle switches (not kidding). They give the same reasons you do.
Would you advise an assembly programmer to try out C# 2.0? If so, perhaps you should try C# 3.5 for the same reasons. If not, keep enjoying C# 2.0, and know that people will, one day soon, see you the same way we see assembly programmers today. :-)
C# 3.5 is much better at letting you build higher-level abstractions than C# 2.0, just as C# 2.0 is better at this than C, and C than assembly. After all, isn't that why we program in HLLs in the first place?
回答10:
It seems like every app needs to communicate with other apps now. So,
- WCF
Having written a TCP communication library in the past, I would have been thrilled, overjoyed, ecstatic, and otherwise quite happy if I had been able to save those months by spending 1 day with WCF.
回答11:
The features I use the most are:
- LINQ
- Extension methods
- Automatic properties
If you haven't used LINQ, and you try it, I think you will find that it (can be) a very powerful tool.
回答12:
How far behind are you willing to be? .NET 4 is coming soon. Cloud (via Azure or even Live Mesh) computing is the next wave, so you'll probably want to be ready for network connectivity by knowing WCF.
If you don't want to learn the new stuff, then you'll still be able to create some good desktop apps with 2.0. But part of being a developer is understanding what's coming next. Even if you don't choose to target a later version of the framework, you should at least spend some time to learn a bit of LINQ, WPF and WCF so that you know their power. Then when you need something that is only available in a later version of the framework, you'll know why you're using it and also should be able to justify the framework download to your clients.
回答13:
I won't convince you to move to 3.5, if you are creating desktop apps for an audience that will find it burdensome to upgrade (e.g. pre-Vista users on slow bandwidth connections). After all the customer comes first.
As mentioned by several others, you can use many new features of the C# compiler even if you target 2.0 (e.g. object initializers, automatic properties), check this out for details. Also, you can use LINQ on 2.0 as well, using the LinqBridge library, which is very small and can be distributed with your app (this is Linq to Objects, not Linq to SQL)
回答14:
If you are creating or consuming web services, then you should be aware that Microsoft now considers ASMX web services to be "legacy technology". All new web service development should be done using WCF - which is not available until .NET 3.0, and gets quite mature and stable at .NET 3.5.
回答15:
Shouldn't the request really be "Convince my users/customers to move from .NET 2.0 to 3.5"
You didn't say whether you're writing code for a customer/user or just as a hobby. If it's the latter then yes, it's all about convincing you.
Otherwise, I can't see your customer being really excited about you being able to use Linq in your code, unless it will let you get things done substantially quicker and more reliably then before.
Of course if you're an experienced 2.0 developer you most likely are already very efficient even without lambdas, query syntax etc. Sure, they would provide some improvements but probably not great enough to excite your customer.
Now, if your customer comes to you and says, I want my new desktop application to have a GUI like one of those web pages with fancy animations etc, then it's obvious. You should seriously look at going to .NET 3.0/3.5 for Windows Presentation Foundation etc.
In summary, if there is a real and tangible reason to use newer technologies, go for it, otherwise it's often costly to get up to speed with a new platform/environment without direct benefit.
回答16:
To be honest, reading most responses the reasons they give are mostly around language enhancements. But if you have no need for that, i'd be tempted to stick with 2.0 for the reason you state ie. broad accessibly, and avoid the platform compatibility nightmare we've had here....
回答17:
If you often use repeater in Asp.Net like controls the ListView control is a much cleaner and easier to work with alternative available to asp.net 3.5.
I also use the routing module from MVC from time to time and find it much better for small sites than something like url rewriting.
回答18:
Read this blog http://weblogs.asp.net/scottgu/archive/2007/11/19/visual-studio-2008-and-net-3-5-released.aspx
From here you will get better idea on .Net 3.5 and VS 2008.
Why the higher version is coming is that,higher version is having easy for development and also having high performance :)
回答19:
I use 3.5 for my main project at the moment, and there are so many advantages. LINQ, Entity Framework, WPF (especially for databinding), LINQ, extension methods, automatic properties, LINQ, oh and Lambda Expressions (those are awesome)! And did i mention LINQ?
That being said, i still use .NET 2.0 for smaller projects where there isn't much code or anything fancy, such as file conversion utilities or some small tool sitting in the tray for just a few tasks.
I always use the lowest framework version that i can, as long as it fullfills all my requirements. So if it's just a small tool, i might go with 2.0, if i want a nice UI, i use 3.0, and if have a lot of database stuff to do, i use 3.5 SP1 with Entity Framework.
回答20:
Because of .NET 3.51 client profile, which has runtime size comparable to .net 2.0!
来源:https://stackoverflow.com/questions/1359974/convince-me-to-move-to-net-3-5-from-2-0