Nihad Huseynov
Nihad Huseynov

Reputation: 123

C# language versioning when automatically selected based on framework version

I have to update the C# version. Now, I use version 7.3 but I need to use 8 or greater version.

While applying the steps in this link, I faced with the problem as it can be seen in the image.

enter image description here

How can I solve this problem? Is there any way to make it manual instead of automatic?

Upvotes: 12

Views: 2683

Answers (1)

SuperTx2
SuperTx2

Reputation: 86

If you edit your .csproj add this line inside the first <PropertyGroup>

<LangVersion>latest</LangVersion>

or if you want to specify the version

<LangVersion>8.0</LangVersion>

In other words:

  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{68EAC5EC-1EE6-4B41-BCF8-ED62CA1B6364}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>SqlServerCLRFunctions</RootNamespace>
    <AssemblyName>SqlServerCLRFunctions</AssemblyName>
    <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <Deterministic>true</Deterministic>
    <LangVersion>8.0</LangVersion> <!-- added, default is C# 7.3 -->
  </PropertyGroup>

Upvotes: 7

Related Questions