Visual Studio 2017 provides you an easy way to upgrade your project's targeted language version, directly from the editor window. The Light Bulb, which is known as Quick Actions, automatically suggests you to upgrade the language version.
In this blog post, we will learn how to invoke it to perform the change for the associated project. Continue reading to learn more.
In the previous post (How to change the default language version in Visual Studio?) we learned how to change the targeted language version of your application by manually changing the project properties within the Visual Studio IDE. In the next few points, we will learn how this can be easily upgradable, whenever needed, by using the Visual Studio Quick Actions (Light Bulb):
Let's assume that you have a C# project, which is targeted to C# 3 as the default language version. Now, you have some requirement that you added some code targeting C# 6.
Let's assume you added a static namespace which is introduced with C# 6. You will encounter an error and a light-bulb (Quick Actions) will pop-up with an option to upgrade your project. Here's a screenshot of the same:
You can select the first option to upgrade the project to 'default
' version that the Visual Studio supports. By default, it points to C# latest major version
. If you want to upgrade the project to the specific version (in our case, it is C# 6), you can select the second option as demonstrated below:
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.
Similarly, if your latest code is from any minor upgrade version of C# 7.x, then it will give you option to either upgrade to latest
or to the specific minor version, which is C# 7.2 in the below case:
To know more about the upgrade versioning, read my previous post: How to change the default language version in Visual Studio?. I hope that the post was helpful. Stay tuned to learn more tips on Visual Studio.