I'm using Visual Studio 2019 with SDK based project, with multiple targets:
<TargetFrameworks>netstandard2.0;net45;net46</TargetFrameworks>
But when I write conditional code, I see (obviously) some code in gray and some code in regular colors :
Question:
What settings decide which section will be gray and which will not?
Because now, if I want to edit the "NETFULL
" section (because I'm multitargeting), it's all gray and I don't have intellisense.
How can I tell VS: now let's switch to NETFULL
mode?
NB Sure I can remove the condition but I want to know why is it gray and how can I switch between them ( since I'm multitargeting)
To switch between the frameworks you are targeting use the dropdown at the top left of the code pane:
Conditional-compilation symbols are declared in the .csproj file:
<PropertyGroup Condition="'$(TargetFramework)' == 'net45' OR '$(TargetFramework)' == 'net46'">
<DefineConstants>NETFULL</DefineConstants>
</PropertyGroup>
or you can use the predefined symbols such as NETFRAMEWORK
, NETSTANDARD
or NETCOREAPP
(or the versioned predefined symbols such as NETSTANDARD2_0
).