What .NET Framework and C# version should I target with my class library?

后端 未结 12 1072
故里飘歌
故里飘歌 2020-12-29 11:04

I\'m building a DLL class library - I want to make it usable by as many people as possible. Which version of the .NET Framework and which C# version should I use? Is it po

12条回答
  •  天命终不由人
    2020-12-29 11:53

    Personally, I'd target .NET 2.0. This means, among other things:

    • No extension methods (there is a workaround though)
    • No linq

    • you CAN use lambda expressions

    • you CAN use the 'var' keyword

    The thing is, you can use C# 3.x language features (the so-called syntactic sugar), but you can't use libraries that target C# 3.x (System.Core to name one, includes extension methods and linq).

    I wouldn't try to support C# 1.x, as it's quite different from C# 2.x and higher. Besides, I expect most people who would use your library are people building new things, who wouldn't in their right minds use C# 1.x ;-)

提交回复
热议问题