我正在开发一款“控制台游戏引擎”,但它只能在Windows 10上运行,因为在其他版本中无法正确显示“自定义颜色”,比如Win8,相反它们只是一堆Unicode代码。
所以我想检查Windows的版本是否为10,并且我做了这个:
var workingSysVer = Environment.OSVersion.Version.ToString().Substring(0, 2);
if (workingSysVer != "10")
{
Console.Title = "OS Version Warning";
// other code
}
有没有更好的方法检查 Windows 版本?
.StartWith("Windows 10")
... 这就是为什么微软将不得不跳过 Windows 100 ;) - omajid