我的操作系统版本字符串如下:
ORDER BY (CASE WHEN [Submission Date] IS NULL
THEN GETDATE()
ELSE [Submission Date]
END) DESC
Microsoft Windows 7 Professional 6.1.7601 Service Pack 1
Microsoft Windows NT 5.1.2600 Service Pack 3
我如何将这些字符串值解析为Version
类?
答案 0 :(得分:1)
您可以使用空格分割字符串a获取字符串版本:
string Os = "Microsoft Windows 7 Professional 6.1.7601 Service Pack 1";
string[] splitOs = Os.Split(null);
foreach (var item in splitOs)
{
if (item.Contains("."))
{
Version v1 = new Version(item)
}
}