The easiest solution here is to simply: use C# 6 (or later). In the csproj, this is the <LangVersion>
property. For example:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<LangVersion>6</LangVersion> <!-- or higher -->
<!-- ... -->
</PropertyGroup>
<!-- ... -->
</Project>
As long as your build tools are up to date, you can use later C# versions with earlier .NET Framework versions - the two things are not strictly coupled.
Note that some language features require additional types to exist (init-only members, for example), and some features require specific runtimes (default interface implementations, for example) - however, if the compiler detects that you're trying to use a C# feature that is missing something it needs: it will just tell you. It doesn't need anything to use nameof
.
Note that the IDE now deliberately limits your ability to select unusual language versions, and it isn't strictly supported - but: it works just fine in every interesting realistic scenario. I'm not "in the loop" on the reasons for that, but I speculate that this is simply to reduce support overheads, i.e. questions - meaning: it becomes much simpler to describe what features are available.