Convince me to move to .net 3.5 (from 2.0) [closed

2020-02-16 12:25发布

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?

20条回答
我只想做你的唯一
2楼-- · 2020-02-16 12:36

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)

查看更多
家丑人穷心不美
3楼-- · 2020-02-16 12:37

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.

查看更多
狗以群分
4楼-- · 2020-02-16 12:37

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.

查看更多
唯我独甜
5楼-- · 2020-02-16 12:41

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.

查看更多
祖国的老花朵
6楼-- · 2020-02-16 12:44

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楼-- · 2020-02-16 12:44

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.

查看更多
登录 后发表回答