giovedì 2 luglio 2015

Retrieve the version of the .NET runtime

Sometimes the simplest questions remains unanswered: what's the .NET runtime version executes my app? .NET 4.0 or .Net 4.5?
Hier you find a simple C# function to retrieve the version of the .NET runtime on which your app is executed.

public static string RetrieveHumanRuntimeVersion()
{
 string text = Environment.Version.ToString();
 if (!text.StartsWith("4.0.30319.")) return text;
 int build, start = text.LastIndexOf('.');
 if (!Int32.TryParse(text.Substring(start + 1), out build)) return text;
 if (build <= 17000) return ".NET 4.0";
 if (build <= 19000) return ".NET 4.5";
 if (build <= 34000) return ".NET 4.5.1";
 return ".NET 4.5.2";
}

More details here

Nessun commento:

Posta un commento