Reputation: 3834
I am having OS version string like:
Microsoft Windows 7 Professional 6.1.7601 Service Pack 1
Microsoft Windows NT 5.1.2600 Service Pack 3
Microsoft Windows Storage Server 2008 R2 Essentials 6.1.7601 Service Pack 1
How could I parse those string values into Version
class?
Upvotes: 0
Views: 195
Reputation: 3012
You can split your string with a space a get the string version:
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)
}
}
Upvotes: 1