Lesson 8 / 26
Target Framework and Language Version
Choose a target framework and understand how the C# language version follows it.
TargetFramework
TargetFramework such as net10.0 says which .NET APIs your project may use. Prefer a Long-Term Support (LTS) release for production because it gets patches for longer.
Pieces that fit together
A solution groups projects, projects reference each other, and NuGet supplies outside libraries.
Multi-targeting a library
A shared library can build for several frameworks at once. Note the plural TargetFrameworks.
<PropertyGroup>
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
</PropertyGroup>Language version follows the framework
Each target framework has a default C# version, so you rarely set LangVersion yourself. Forcing a newer one on an old framework can break features that need runtime support.
Quick check: Why choose an LTS release for production?
- It receives fixes for a longer time
- It is always faster
- It needs no SDK
- It is the only one that runs on Linux
Answer
It receives fixes for a longer time — LTS releases are supported longer, which reduces forced upgrades.