1
class
Program
2
{
3
static
void
Main(
string
[] args)
4
{
5
OperatingSystem osObj
=
System.Environment.OSVersion;
6
Console.WriteLine(
"
PlatForm is:{0}
"
, osObj.Platform);
7
Console.WriteLine(
"
Service Pack is:{0}
"
, osObj.ServicePack);
8
Console.WriteLine(
"
Version is:{0}
"
, osObj.Version);
9
Console.WriteLine(
"
VersionString is:{0}
"
, osObj.VersionString);
10
Console.WriteLine(
"
CLR Version is:{0}
"
, System.Environment.Version);
11
Console.ReadKey();
12
}
13
}
14
須要注意的是,OSVersion類不會直接提供詳細的例如「Windows Vista」或者「Windows 7」這樣的操做系統品牌,你應該經過相應的系統版本號來代替。code