本文整理汇总了C#中System.OperatingSystem.Platform属性的典型用法代码示例。如果您正苦于以下问题:C# OperatingSystem.Platform属性的具体用法?C# OperatingSystem.Platform怎么用?C# OperatingSystem.Platform使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.OperatingSystem
的用法示例。
在下文中一共展示了OperatingSystem.Platform属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildOSObj
// Example for the OperatingSystem.Platform and
// OperatingSystem.Version properties.
using System;
class PlatformVersionDemo
{
// Create an OperatingSystem object and display the Platform
// and Version properties.
static void BuildOSObj( PlatformID pID, Version ver )
{
OperatingSystem opSys = new OperatingSystem( pID, ver );
PlatformID platform = opSys.Platform;
Version version = opSys.Version;
Console.WriteLine( " Platform: {0,-15} Version: {1}",
platform, version );
}
static void BuildOperatingSystemObjects( )
{
// The Version object does not need to correspond to an
// actual OS version.
Version verNull = new Version( );
Version verString = new Version( "3.5.8.13" );
Version verMajMin = new Version( 6, 10 );
Version verMMBld = new Version( 5, 25, 5025 );
Version verMMBVer = new Version( 5, 6, 7, 8 );
// All PlatformID members are shown here.
BuildOSObj( PlatformID.Win32NT, verNull );
BuildOSObj( PlatformID.Win32S, verString );
BuildOSObj( PlatformID.Win32Windows, verMajMin );
BuildOSObj( PlatformID.WinCE, verMMBld );
BuildOSObj( PlatformID.Win32NT, verMMBVer );
}
static void Main( )
{
Console.WriteLine(
"This example of OperatingSystem.Platform " +
"and OperatingSystem.Version \n" +
"generates the following output.\n" );
Console.WriteLine(
"Create several OperatingSystem objects " +
"and display their properties:\n" );
BuildOperatingSystemObjects( );
Console.WriteLine(
"\nThe operating system of the host computer is:\n" );
BuildOSObj(
Environment.OSVersion.Platform,
Environment.OSVersion.Version );
}
}
输出:
Create several OperatingSystem objects and display their properties: Platform: Win32NT Version: 0.0 Platform: Win32S Version: 3.5.8.13 Platform: Win32Windows Version: 6.10 Platform: WinCE Version: 5.25.5025 Platform: Win32NT Version: 5.6.7.8 The operating system of the host computer is: Platform: Win32NT Version: 5.1.2600.0