Version.MajorRevision 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取修订号的高 16 位。
public:
property short MajorRevision { short get(); };
public short MajorRevision { get; }
member this.MajorRevision : int16
Public ReadOnly Property MajorRevision As Short
属性值
16 位带符号整数。
示例
下面的代码示例演示构造Version函数以及 Major、Minor、、BuildRevision、 MajorRevision和 MinorRevision 属性。
// This example demonstrates the Version.Revision,
// MajorRevision, and MinorRevision properties.
using namespace System;
int main()
{
String^ formatStandard = "Standard version:\n" +
" major.minor.build.revision = {0}.{1}.{2}.{3}";
String^ formatInterim = "Interim version:\n" +
" major.minor.build.majRev/minRev = {0}.{1}.{2}.{3}/{4}";
Version^ standardVersion = gcnew Version(2, 4, 1128, 2);
Version^ interimVersion = gcnew Version(2, 4, 1128, (100 << 16) + 2);
Console::WriteLine(formatStandard, standardVersion->Major,
standardVersion->Minor, standardVersion->Build,
standardVersion->Revision);
Console::WriteLine(formatInterim, interimVersion->Major,
interimVersion->Minor, interimVersion->Build,
interimVersion->MajorRevision, interimVersion->MinorRevision);
};
/*
This code example produces the following results:
Standard version:
major.minor.build.revision = 2.4.1128.2
Interim version:
major.minor.build.majRev/minRev = 2.4.1128.100/2
*/
// This example demonstrates the Version.Revision,
// MajorRevision, and MinorRevision properties.
using System;
class Sample
{
public static void Main()
{
string fmtStd = "Standard version:\n" +
" major.minor.build.revision = {0}.{1}.{2}.{3}";
string fmtInt = "Interim version:\n" +
" major.minor.build.majRev/minRev = {0}.{1}.{2}.{3}/{4}";
Version std = new Version(2, 4, 1128, 2);
Version interim = new Version(2, 4, 1128, (100 << 16) + 2);
Console.WriteLine(fmtStd, std.Major, std.Minor, std.Build, std.Revision);
Console.WriteLine(fmtInt, interim.Major, interim.Minor, interim.Build,
interim.MajorRevision, interim.MinorRevision);
}
}
/*
This code example produces the following results:
Standard version:
major.minor.build.revision = 2.4.1128.2
Interim version:
major.minor.build.majRev/minRev = 2.4.1128.100/2
*/
// This example demonstrates the Version.Revision,
// MajorRevision, and MinorRevision properties.
open System
let std = Version(2, 4, 1128, 2)
let interim = Version(2, 4, 1128, (100 <<< 16) + 2)
printfn $"Standard version:\n major.minor.build.revision = {std.Major}.{std.Minor}.{std.Build}.{std.Revision}"
printfn $"Interim version:\n major.minor.build.majRev/minRev = {interim.Major}.{interim.Minor}.{interim.Build}.{interim.MajorRevision}/{interim.MinorRevision}"
// This code example produces the following results:
// Standard version:
// major.minor.build.revision = 2.4.1128.2
// Interim version:
// major.minor.build.majRev/minRev = 2.4.1128.100/2
' This example demonstrates the Version.Revision,
' MajorRevision, and MinorRevision properties.
Class Sample
Public Shared Sub Main()
Dim fmtStd As String = "Standard version:" & vbCrLf & _
" major.minor.build.revision = {0}.{1}.{2}.{3}"
Dim fmtInt As String = "Interim version:" & vbCrLf & _
" major.minor.build.majRev/minRev = {0}.{1}.{2}.{3}/{4}"
Dim std As New Version(2, 4, 1128, 2)
Dim interim As New Version(2, 4, 1128, (100 << 16) + 2)
Console.WriteLine(fmtStd, std.Major, std.Minor, std.Build, std.Revision)
Console.WriteLine(fmtInt, interim.Major, interim.Minor, interim.Build, _
interim.MajorRevision, interim.MinorRevision)
End Sub
End Class
'
'This code example produces the following results:
'
'Standard version:
' major.minor.build.revision = 2.4.1128.2
'Interim version:
' major.minor.build.majRev/minRev = 2.4.1128.100/2
'
注解
假设你发布了应用程序的临时版本,以暂时更正问题,直到可以发布永久解决方案。 临时版本不保证新的修订号,但需要将其标识为不同的版本。 在这种情况下,将标识信息编码为 32 位修订号的高位和低 16 位部分。 Revision使用 属性获取整个修订号,使用 MajorRevision 属性获取高 16 位,使用 MinorRevision 属性获取低 16 位。
从 .NET Framework 版本 2.0 开始,Windows NT操作系统使用 MajorRevision 属性对 Service Pack 编号进行编码。