This is my solution, fastest and without select cases.
the result may be customized as you want
public static string SistemaOperativo
{
get
{
#region Dichiarazioni
var osInfo = Environment.OSVersion;
int platformID = (int)osInfo.Platform;
int versionM = osInfo.Version.Major;
int versionm = osInfo.Version.Minor;
string servicePack = osInfo.ServicePack;
#endregion
#region Spiegazione logica
/*
* IT:
* La chiave del dizionario è il risultato del concatenamento di
* PlatformID,MajorVersion,MinorVersion, tutto convertito in Int32,
* per esempio Platform ID=1 MajorVersion=4 MinorVersion=0,
* il risultato è 140 ossia Windows 95
*
* EN:
* The key in Dictionary is the 'join'
* of PlatformID,MajorVersion,MinorVersion, in int32,
* eg. Platform ID=1 MajorVersion=4 MinorVersion=0,
* the result is '140' (Windows 95)
*/
#endregion
Dictionary<int, string> sistemiOperativi = new Dictionary<int, string>(){
{0, "Windows 3.1"},
{140, "Windows 95"},
{1410, "Windows 98"},
{1490, "Windows ME"},
{2351, "Windows NT 3.51"},
{240, "Windows 4.0"},
{250, "Windows 2000"},
{251, "Windows XP"},
{252, "Windows 2003"},
{260, "Windows Vista/Server 2008"},
{261, "Windows 7"},
{-1, "Unknown"}
};
int idUnivoco = int.Parse(string.Format("{0}{1}{2}", platformID, versionM, versionm));
string outValue = "";
if (sistemiOperativi.TryGetValue(idUnivoco, out outValue))
return string.Format("{0}{1}", outValue, servicePack);
return sistemiOperativi[-1];
}
}