Muokkaa

Jaa


Version Class

Definition

Represents the version number of an assembly, operating system, or the common language runtime. This class cannot be inherited.

public ref class Version sealed : IComparable, IComparable<Version ^>, IEquatable<Version ^>
public ref class Version sealed : ICloneable, IComparable, IComparable<Version ^>, IEquatable<Version ^>
public ref class Version sealed : ICloneable, IComparable, IComparable<Version ^>, IEquatable<Version ^>, ISpanFormattable
public ref class Version sealed : ICloneable, IComparable, IComparable<Version ^>, IEquatable<Version ^>, ISpanFormattable, IUtf8SpanFormattable
public ref class Version sealed : ICloneable, IComparable
public sealed class Version : IComparable, IComparable<Version>, IEquatable<Version>
public sealed class Version : ICloneable, IComparable, IComparable<Version>, IEquatable<Version>
public sealed class Version : ICloneable, IComparable, IComparable<Version>, IEquatable<Version>, ISpanFormattable
public sealed class Version : ICloneable, IComparable, IComparable<Version>, IEquatable<Version>, ISpanFormattable, IUtf8SpanFormattable
[System.Serializable]
public sealed class Version : ICloneable, IComparable
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class Version : ICloneable, IComparable, IComparable<Version>, IEquatable<Version>
type Version = class
    interface IComparable
    interface IComparable<Version>
    interface IEquatable<Version>
type Version = class
    interface ICloneable
    interface IComparable
    interface IComparable<Version>
    interface IEquatable<Version>
type Version = class
    interface ICloneable
    interface IComparable
    interface IComparable<Version>
    interface IEquatable<Version>
    interface ISpanFormattable
    interface IFormattable
type Version = class
    interface ICloneable
    interface IComparable
    interface IComparable<Version>
    interface IEquatable<Version>
    interface IFormattable
    interface ISpanFormattable
type Version = class
    interface ICloneable
    interface IComparable
    interface IComparable<Version>
    interface IEquatable<Version>
    interface IFormattable
    interface ISpanFormattable
    interface IUtf8SpanFormattable
type Version = class
    interface IComparable
    interface IComparable<Version>
    interface IEquatable<Version>
    interface ICloneable
[<System.Serializable>]
type Version = class
    interface ICloneable
    interface IComparable
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type Version = class
    interface ICloneable
    interface IComparable
    interface IComparable<Version>
    interface IEquatable<Version>
Public NotInheritable Class Version
Implements IComparable, IComparable(Of Version), IEquatable(Of Version)
Public NotInheritable Class Version
Implements ICloneable, IComparable, IComparable(Of Version), IEquatable(Of Version)
Public NotInheritable Class Version
Implements ICloneable, IComparable, IComparable(Of Version), IEquatable(Of Version), ISpanFormattable
Public NotInheritable Class Version
Implements ICloneable, IComparable, IComparable(Of Version), IEquatable(Of Version), ISpanFormattable, IUtf8SpanFormattable
Public NotInheritable Class Version
Implements ICloneable, IComparable
Inheritance
Version
Attributes
Implements

Examples

The following example uses the AssemblyVersionAttribute attribute to assign a version number to an assembly. At compile time, this version information is stored with the assembly's metadata. At run time, the example retrieves the value of the Type.Assembly property on a type found in the assembly to get a reference to the executing assembly, and it retrieves the assembly's version information from the Version property of the AssemblyName object returned by the Assembly.GetName method.

using System;
using System.Reflection;

[assembly:AssemblyVersionAttribute("2.0.1")]

public class Example1
{
   public static void Main()
   {
      Assembly thisAssem = typeof(Example1).Assembly;
      AssemblyName thisAssemName = thisAssem.GetName();
       
      Version ver = thisAssemName.Version;
       
      Console.WriteLine("This is version {0} of {1}.", ver, thisAssemName.Name);    
   }
}
// The example displays the following output:
//        This is version 2.0.1.0 of Example1.
open System.Reflection

[<assembly: AssemblyVersionAttribute "2.0.1">]
do ()

type Example1 = class end

let thisAssem = typeof<Example1>.Assembly
let thisAssemName = thisAssem.GetName()
   
let ver = thisAssemName.Version
   
printfn $"This is version {ver} of {thisAssemName.Name}."
// The example displays the following output:
//        This is version 2.0.1.0 of Example1.
Imports System.Reflection

<Assembly:AssemblyVersionAttribute("2.0.1")>
Module Example1
   Public Sub Main()
       Dim thisAssem As Assembly = GetType(Example1).Assembly
       Dim thisAssemName As AssemblyName = thisAssem.GetName()
       
       Dim ver As Version = thisAssemName.Version
       
       Console.WriteLine("This is version {0} of {1}.", ver, thisAssemName.Name)    
   End Sub
End Module
' The example displays the following output:
'      This is version 2.0.1.0 of Example1.

Remarks

For more information about this API, see Supplemental API remarks for Version.

Constructors

Version()

Initializes a new instance of the Version class.

Version(Int32, Int32, Int32, Int32)

Initializes a new instance of the Version class with the specified major, minor, build, and revision numbers.

Version(Int32, Int32, Int32)

Initializes a new instance of the Version class using the specified major, minor, and build values.

Version(Int32, Int32)

Initializes a new instance of the Version class using the specified major and minor values.

Version(String)

Initializes a new instance of the Version class using the specified string.

Properties

Build

Gets the value of the build component of the version number for the current Version object.

Major

Gets the value of the major component of the version number for the current Version object.

MajorRevision

Gets the high 16 bits of the revision number.

Minor

Gets the value of the minor component of the version number for the current Version object.

MinorRevision

Gets the low 16 bits of the revision number.

Revision

Gets the value of the revision component of the version number for the current Version object.

Methods

Clone()

Returns a new Version object whose value is the same as the current Version object.

CompareTo(Object)

Compares the current Version object to a specified object and returns an indication of their relative values.

CompareTo(Version)

Compares the current Version object to a specified Version object and returns an indication of their relative values.

Equals(Object)

Returns a value indicating whether the current Version object is equal to a specified object.

Equals(Version)

Returns a value indicating whether the current Version object and a specified Version object represent the same value.

GetHashCode()

Returns a hash code for the current Version object.

GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
Parse(ReadOnlySpan<Char>)

Converts the specified read-only span of characters that represents a version number to an equivalent Version object.

Parse(String)

Converts the string representation of a version number to an equivalent Version object.

ToString()

Converts the value of the current Version object to its equivalent String representation.

ToString(Int32)

Converts the value of the current Version object to its equivalent String representation. A specified count indicates the number of components to return.

TryFormat(Span<Byte>, Int32, Int32)

Tries to format this version instance into a span of bytes.

TryFormat(Span<Byte>, Int32)

Tries to format this version instance into a span of bytes.

TryFormat(Span<Char>, Int32, Int32)

Tries to format this version instance into a span of characters.

TryFormat(Span<Char>, Int32)

Tries to format this version instance into a span of characters.

TryParse(ReadOnlySpan<Char>, Version)

Tries to convert the specified read-only span of characters representing a version number to an equivalent Version object, and returns a value that indicates whether the conversion succeeded.

TryParse(String, Version)

Tries to convert the string representation of a version number to an equivalent Version object, and returns a value that indicates whether the conversion succeeded.

Operators

Equality(Version, Version)

Determines whether two specified Version objects are equal.

GreaterThan(Version, Version)

Determines whether the first specified Version object is greater than the second specified Version object.

GreaterThanOrEqual(Version, Version)

Determines whether the first specified Version object is greater than or equal to the second specified Version object.

Inequality(Version, Version)

Determines whether two specified Version objects are not equal.

LessThan(Version, Version)

Determines whether the first specified Version object is less than the second specified Version object.

LessThanOrEqual(Version, Version)

Determines whether the first specified Version object is less than or equal to the second Version object.

Explicit Interface Implementations

IComparable.CompareTo(Object)

Compares the current Version object to a specified object and returns an indication of their relative values.

IFormattable.ToString(String, IFormatProvider)

Formats the value of the current instance using the specified format.

ISpanFormattable.TryFormat(Span<Char>, Int32, ReadOnlySpan<Char>, IFormatProvider)

Tries to format the value of the current instance into the provided span of characters.

IUtf8SpanFormattable.TryFormat(Span<Byte>, Int32, ReadOnlySpan<Char>, IFormatProvider)

Tries to format the value of the current instance as UTF-8 into the provided span of bytes.

Applies to