-2

For the life of me I cannot find out how to view or change the C# version in my project. I'm using VS2010 and C# .Net 2.0 and have found (from an error message) that the project is using ISO-2 C#. (Note, I don't even get the option to choose a version when creating a new project.)

I have Googled the hell out of this problem and found nothing at all, other than discussions about different versions.

Can anyone tell me how I can change the version of C# my project is using?

user2771704
  • 5,204
  • 6
  • 33
  • 38
Reinstate Monica Cellio
  • 24,939
  • 6
  • 47
  • 65

2 Answers2

1

As far as I know, C# version is tied to .Net version.

Numbers of versions are not the same, but if you want extra features like lambda, late binding etc, you need to up your .Net version.

.Net Versions:

  • 1.0 - released in 2002
  • 1.1 - released in 2003
  • 2.0 - released in 2005, with a new CLR (to handle generics and nullable types) and compilers for C# 2 and VB 8.
  • 3.0 - released in 2006, this is just 2.0 plus new libraries: Windows Presentation Foundation, Windows Communication Foundation, Workflow Foundation, and Cardspace
  • 3.5 - released in 2007, this is 3.0 plus new libraries (primarily LINQ and some extra "base" libraries such as TimeZoneInfo) and new compilers (for C# 3 and VB 9)
  • 4 - released in 2010, this includes a new CLR (v4), new libraries, and the DLR (Dynamic Language Runtime)
  • 4.5 - released in 2012, this allows for WinRT development on Windows 8 as well as extra libraries - with much wider async APIs

C# versions:

  • C# 1
  • C# 2, introducing generics, nullable types, anonymous methods, iterator blocks and some other more minor features
  • C# 3, introducing implicit typing, object and collection initializers, anonymous types, automatic properties, lambda expressions, extension methods, query expressions and some other minor features
  • C# 4, introducing dynamic typing, optional parameters, named arguments, and generic variance
  • C# 5, introducing asynchronous functions, caller info attributes, and a tweak to foreach iteration variable capture

info can be found here:

http://csharpindepth.com/articles/chapter1/versions.aspx

you can change the c# version if you'd like to. Right click on project, select properties ---> build ---> advanced ---> language version

but this can be really tricky.

Check here:

Difference between compiling as C# 3.0 or ISO-1 or ISO-2?

Community
  • 1
  • 1
avidenic
  • 624
  • 7
  • 17
1

If you want to change the version of C# from ISO-2 to default you can open the project file in your favourite editor and search for the line:

<LangVersion>ISO-2</LangVersion>

and change it to

<LangVersion>default</LangVersion>

or if you want to use C# 3.0 change it to

<LangVersion>3</LangVersion>

For using another .NET version you would right click your project -> properties and on the application tabpage you need to change the target framework platform.

For the C# version numbers please see: https://stackoverflow.com/a/247623/2655508

Community
  • 1
  • 1
Heslacher
  • 1,967
  • 19
  • 34