Classes you didn’t know about: System.Runtime.Versioning.FrameworkName

Posted: (EET/GMT+2)

 

Chances are you've looked into building your own NuGet packages with C#, or you have worked with the many different .NET framework versions and profiles that have been developed during the years. In case you need to programmatically get information about a particular .NET framework version and especially parse a version string, there's a nice little helper class built into the .NET Framework: FrameworkName.

This class lives in the System.Runtime.Versioning namespace, and can take a string in the following format:

.NETFramework,Version=v4.0.2

Out of a similarly formatted string, it can parse out the various parts and give them out as easy property values.

Hope this helps!