How do I find the C# version I’m using?

Asked

Viewed 2,496 times

6

I wanted to know how to find out the version of C# I’m using.

  • 1

    Control panel => programs and resources :D

  • @Articuno this is serious?

  • This is the. net framework version. No???

  • @Wallacemaxters one thing that has not become clear is whether you want to know if it is Vs, while running, or otherwise

3 answers

8


It is possible to verify the version through code as well:

string version = typeof(string).Assembly.ImageRuntimeVersion;

However, from what I was analyzing, the version informed by ImageRuntimeVersion is not the correct version of C#.

The C# version depends on which . NET Framework you are using.

  • C# 1.0 launched with . NET 1.0 and VS2002
  • C# 1.2 (bizarre enough) released with . NET 1.1 and VS2003
  • C# 2.0 launched with . NET 2.0 and VS2005
  • C# 3.0 launched with . NET 3.5 and VS2008
  • C# 4.0 launched with . NET 4 and VS2010
  • C# 5.0 launched with . NET 4.5 and VS2012
  • C# 6.0 launched with . NET 4.6 and VS2015
  • C# 7.0 launched with . NET 4.6.2 and VS2017
  • C# 7.1 launched with VS2017 v15.3
  • C# 7.2 launched with VS2017 v15.5

C# Language Team created a history of C# versions and their features in the repository github theirs:

Information collected from:

4

  • Click the project file (usually a csproj) with the right button
  • Properties
  • Build
  • Advanced
  • In the section general has language version

  • Gee! There’s no csproj in Webforms :\

  • But there’s a project file

  • 1

    Wouldn’t right-click the project, Properties and application tab to check the target framework?

  • The version of "Target Framework" is like ". Net Framework 4.5". But it has some relation with the version of C#? (I was in doubt now)

  • @Wallacemaxters You don’t have

  • By selecting a project from your solution and following the steps @LINQ went through, you can check the C# version yes, I just took the test.

  • @Leandroangelo No. There is no direct relationship between the language version and the framework.

Show 2 more comments

4

As far as I know there is no information at runtime, can only get from the framework.

Compiler says his version calls itself in command line. But it doesn’t say which version of the language, because it can compile with a different version profile. You can at least know until which version it compiles.

Try this on the project:

Linguagem da projeto

If none of this works out, and it has to, try using a feature that you only have in a certain version, if it works you know that at least that version is ok. If you make a mistake, you know you have a lower version, then you go for a trial and error up or down :) I know it’s Ambi, but it’s the way if nothing else goes right.

  • https://www.codeproject.com/Tips/865579/How-to-change-targeted-Csharp-version-in-Visual-St

Browser other questions tagged

You are not signed in. Login or sign up in order to post.