string framework = System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription; Console.WriteLine(framework);
using System; class Program { static void Main(string[] args) { Version frameworkVersion = Environment.Version; Console.WriteLine(frameworkVersion); bool compatible = frameworkVersion >= new Version(4,7,2); Console.WriteLine($"Is compatible: {compatible}"); } }This code example uses the Environment class to retrieve the framework version and checks if it is compatible with a specified version (4.7.2 in this case). Package library determined: .NET Framework