Recently, while building a small utility, I need to check the version of the .NET runtime that it was running under.

The quickest way is to consult the Environment.Version property.

Console.WriteLine(Environment.Version);

runtimeVersion

If you need more granular information, you can check

This is because what is returned is a version object.

TLDR

You can query the .NET version running from the Environment.Version property.

Happy hacking!