Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class System.​Version

Assembly: System.Runtime

Inheritance: object → Version

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

Properties

public int
Build
Gets the value of the build component of the version number for the current <see cref="T:System.Version" /> object.
public int
Major
Gets the value of the major component of the version number for the current <see cref="T:System.Version" /> object.
public short
MajorRevision
Gets the high 16 bits of the revision number.
public int
Minor
Gets the value of the minor component of the version number for the current <see cref="T:System.Version" /> object.
public short
MinorRevision
Gets the low 16 bits of the revision number.
public int
Revision
Gets the value of the revision component of the version number for the current <see cref="T:System.Version" /> object.

Methods

public object
Clone​()
Returns A new <see cref="T:System.Object" /> whose values are a copy of the current <see cref="T:System.Version" /> object.
Returns a new <see cref="T:System.Version" /> object whose value is the same as the current <see cref="T:System.Version" /> object.
public int
CompareTo​(object version)
version An object to compare, or <see langword="null" /> .
Returns A signed integer that indicates the relative values of the two objects, as shown in the following table. <list type="table"> <listheader> <term> Return value</term> <description> Meaning</description> </listheader> <item> <term> Less than zero</term> <description> The current <see cref="T:System.Version" /> object is a version before <paramref name="version" />.</description> </item> <item> <term> Zero</term> <description> The current <see cref="T:System.Version" /> object is the same version as <paramref name="version" />.</description> </item> <item> <term> Greater than zero</term> <description> The current <see cref="T:System.Version" /> object is a version subsequent to <paramref name="version" />, or <paramref name="version" /> is <see langword="null" />.</description> </item> </list>
Compares the current <see cref="T:System.Version" /> object to a specified object and returns an indication of their relative values.
public int
CompareTo​(Version value)
value A <see cref="T:System.Version" /> object to compare to the current <see cref="T:System.Version" /> object, or <see langword="null" /> .
Returns A signed integer that indicates the relative values of the two objects, as shown in the following table. <list type="table"> <listheader> <term> Return value</term> <description> Meaning</description> </listheader> <item> <term> Less than zero</term> <description> The current <see cref="T:System.Version" /> object is a version before <paramref name="value" />.</description> </item> <item> <term> Zero</term> <description> The current <see cref="T:System.Version" /> object is the same version as <paramref name="value" />.</description> </item> <item> <term> Greater than zero</term> <description> The current <see cref="T:System.Version" /> object is a version subsequent to <paramref name="value" />, or <paramref name="value" /> is <see langword="null" />.</description> </item> </list>
Compares the current <see cref="T:System.Version" /> object to a specified <see cref="T:System.Version" /> object and returns an indication of their relative values.
public bool
Equals​(object obj)
obj An object to compare with the current <see cref="T:System.Version" /> object, or <see langword="null" /> .
Returns <see langword="true" /> if the current <see cref="T:System.Version" /> object and <paramref name="obj" /> are both <see cref="T:System.Version" /> objects, and every component of the current <see cref="T:System.Version" /> object matches the corresponding component of <paramref name="obj" /> ; otherwise, <see langword="false" /> .
Returns a value indicating whether the current <see cref="T:System.Version" /> object is equal to a specified object.
public bool
Equals​(Version obj)
obj A <see cref="T:System.Version" /> object to compare to the current <see cref="T:System.Version" /> object, or <see langword="null" /> .
Returns <see langword="true" /> if every component of the current <see cref="T:System.Version" /> object matches the corresponding component of the <paramref name="obj" /> parameter; otherwise, <see langword="false" /> .
Returns a value indicating whether the current <see cref="T:System.Version" /> object and a specified <see cref="T:System.Version" /> object represent the same value.
public int
GetHashCode​()
Returns A 32-bit signed integer hash code.
Returns a hash code for the current <see cref="T:System.Version" /> object.
public string
ToString​()
Returns The <see cref="T:System.String" /> representation of the values of the major, minor, build, and revision components of the current <see cref="T:System.Version" /> object, as depicted in the following format. Each component is separated by a period character ('.'). Square brackets ('[' and ']') indicate a component that will not appear in the return value if the component is not defined: major.minor[.build[.revision]] For example, if you create a <see cref="T:System.Version" /> object using the constructor <c>Version(1,1)</c> , the returned string is "1.1". If you create a <see cref="T:System.Version" /> object using the constructor <c>Version(1,3,4,2)</c> , the returned string is "1.3.4.2".
Converts the value of the current <see cref="T:System.Version" /> object to its equivalent <see cref="T:System.String" /> representation.
public string
ToString​(int fieldCount)
fieldCount The number of components to return. The <paramref name="fieldCount" /> ranges from 0 to 4.
Returns The <see cref="T:System.String" /> representation of the values of the major, minor, build, and revision components of the current <see cref="T:System.Version" /> object, each separated by a period character ('.'). The <paramref name="fieldCount" /> parameter determines how many components are returned. <list type="table"> <listheader> <term> fieldCount</term> <description> Return Value</description> </listheader> <item> <term> 0</term> <description> An empty string ("").</description> </item> <item> <term> 1</term> <description> major</description> </item> <item> <term> 2</term> <description> major.minor</description> </item> <item> <term> 3</term> <description> major.minor.build</description> </item> <item> <term> 4</term> <description> major.minor.build.revision</description> </item> </list> For example, if you create <see cref="T:System.Version" /> object using the constructor <c>Version(1,3,5)</c> , <c>ToString(2)</c> returns "1.3" and <c>ToString(4)</c> throws an exception.
Converts the value of the current <see cref="T:System.Version" /> object to its equivalent <see cref="T:System.String" /> representation. A specified count indicates the number of components to return.
public bool
TryFormat​(Span`1 utf8Destination, int fieldCount, Int32& bytesWritten)
public bool
TryFormat​(Span`1 utf8Destination, Int32& bytesWritten)
public bool
TryFormat​(Span`1 destination, int fieldCount, Int32& charsWritten)
public bool
TryFormat​(Span`1 destination, Int32& charsWritten)
protected void
Finalize​()
Inherited from object
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
public Type
GetType​()
Inherited from object
Returns The exact runtime type of the current instance.
Gets the <see cref="T:System.Type" /> of the current instance.
protected object
MemberwiseClone​()
Inherited from object
Returns A shallow copy of the current <see cref="T:System.Object" /> .
Creates a shallow copy of the current <see cref="T:System.Object" /> .