How to change the default language version in Visual Studio?


Do you know that, Visual Studio allows you to select the default language version of your project? The project settings helps you to control the targeted C# language by changing the compiler version. - Article authored by Kunal Chowdhury on .

Do you know that, Microsoft Visual Studio allows you to select the default language version of your project? The advanced project settings helps you to control the targeted C# language by changing the compiler version.

 

By default, the compiler accepts all valid language syntax that it can support. But if you want to change it to point to a specific version, let's learn how to do that.

 

How to change the default language version in Visual Studio?

 

How to change the default language version?

Follow the below mentioned steps in Visual Studio to target a desired C# language version for a specific project:

  1. From the Solution Explorer, right-click on the project node.
  2. Click on Properties from the context menu.
  3. From the project properties screen, navigate to the Build tab.
  4. Scroll down the screen and click Advanced... button, which you can find under the Output section. This will launch the Advanced Build Settings dialog window on the screen.
  5.  

    Visual Studio project build properties

     

  6. If you are using Visual Studio 2015, the Language Version list under the General section of the Advanced Build Settings dialog will look as below:
  7.  

    Visual Studio 2015 advanced build settings

     

  8. If you are using Visual Studio 2017, the Language Version list under the General section of the Advanced Build Settings dialog will look as below:
  9.  

    Visual Studio 2017 advanced build settings

     

  10. Select the C# language version that you want your project to target.
  11. Click OK to save the changes.

 

Do you know?

My book Mastering Visual Studio 2017 is now available on Amazon and Flipkart at a discounted price. Click here to buy it.

 

How it works...

When you select default (Visual Studio 2015) or C# latest major version (default) (Visual Studio 2017), the compiler accepts all valid language syntax that it can support.

 

When you select C# latest minor version (latest) (Visual Studio 2017), the compiler accepts all valid language syntax that it can support in latest minor version of the compiler.

 

When you select ISO-1, the compiler accepts only syntax that is included in ISO/IEC 23270:2003 C# (1.0/1.1). In case of ISO-2, it accepts only syntax that is included in ISO/IEC 23270:2006 C# (2.0).

 

If you like to restrict it to a specific version, select the one that best suits your requirement. For example, selecting C# 3.0 will ask the compiler to accept only those syntax that is included in C# 3.0 and lower. Similarly, selecting C# 4.0 will restrict it to C# 4.0 and lower. You can chose other values like C# 5.0, C# 6.0, C# 7.0, C# 7.1, C# 7.2 from the list.

 

 

Have a question? Or, a comment? Let's Discuss it below...

Thank you for visiting our website!

We value your engagement and would love to hear your thoughts. Don't forget to leave a comment below to share your feedback, opinions, or questions.

We believe in fostering an interactive and inclusive community, and your comments play a crucial role in creating that environment.