System.Version Class
Syntax
Remarks
The Version
class represents version numbers as a sequence of integers. A version number consists of components such as major, minor, build, and revision.
The Version
class provides methods for parsing, comparing, and formatting version numbers.
Constructors
Name | Description |
---|---|
Version() | Initializes a new instance of the Version class. The default version is 0.0.0.0. |
Version(int major) | Initializes a new instance of the Version class with the specified major version. |
Version(int major, int minor) | Initializes a new instance of the Version class with the specified major and minor versions. |
Version(int major, int minor, int build) | Initializes a new instance of the Version class with the specified major, minor, and build versions. |
Version(int major, int minor, int build, int revision) | Initializes a new instance of the Version class with the specified major, minor, build, and revision versions. |
Version(string version) | Initializes a new instance of the Version class using the specified string representation. |
Properties
Name | Description |
---|---|
Build | Gets the build number of the version. |
MajorRevision | Gets the major revision number of the version. |
Major | Gets the major version number of the version. |
Minor | Gets the minor version number of the version. |
MinorRevision | Gets the minor revision number of the version. |
Revision | Gets the revision number of the version. |
Length | Gets the number of components in the version number. |
Methods
Name | Description |
---|---|
Clone() | Creates a new Version object from the current Version object. |
CompareTo(object version) | Compares the current Version object to another object. |
CompareTo(Version value) | Compares the current Version object to another Version object. |
Equals(object obj) | Determines whether the current Version object is equal to another object. |
Equals(Version obj) | Determines whether the current Version object is equal to another Version object. |
GetHashCode() | Returns the hash code for the current Version object. |
Parse(string version) | Converts the specified string representation of a version number to its Version equivalent. |
op_Equality(Version left, Version right) | Compares two Version objects for equality. |
op_Inequality(Version left, Version right) | Compares two Version objects for inequality. |
op_GreaterThan(Version left, Version right) | Compares two Version objects to determine if the first is greater than the second. |
op_GreaterThanOrEqual(Version left, Version right) | Compares two Version objects to determine if the first is greater than or equal to the second. |
op_LessThan(Version left, Version right) | Compares two Version objects to determine if the first is less than the second. |
op_LessThanOrEqual(Version left, Version right) | Compares two Version objects to determine if the first is less than or equal to the second. |
ToString() | Returns a string representation of the current Version object. |
ToString(int fieldCount) | Returns a string representation of the current Version object, using the specified number of components. |
TryParse(string version, out Version result) | Tries to convert the string representation of a version number to its Version equivalent. |
TryParse(string version, System.Globalization.NumberStyles styles, System.IFormatProvider provider, out Version result) | Tries to convert the string representation of a version number to its Version equivalent using specified styles and format provider. |
Version() Constructor
Initializes a new instance of the Version
class. The default version is 0.0.0.0.
Version(int major) Constructor
Initializes a new instance of the Version
class with the specified major version. The minor, build, and revision numbers default to 0.
Version(int major, int minor) Constructor
Initializes a new instance of the Version
class with the specified major and minor versions. The build and revision numbers default to 0.
Version(int major, int minor, int build) Constructor
Initializes a new instance of the Version
class with the specified major, minor, and build versions. The revision number defaults to 0.
Version(int major, int minor, int build, int revision) Constructor
Initializes a new instance of the Version
class with the specified major, minor, build, and revision versions.
[System.Security.SecuritySafeCritical]
Version(string version) Constructor
Initializes a new instance of the Version
class using the specified string representation.
[System.Security.SecuritySafeCritical]
Build Property
Gets the build number of the version.
MajorRevision Property
Gets the major revision number of the version.
Major Property
Gets the major version number of the version.
Minor Property
Gets the minor version number of the version.
MinorRevision Property
Gets the minor revision number of the version.
Revision Property
Gets the revision number of the version.
Length Property
Gets the number of components in the version number.
Clone() Method
Creates a new Version
object from the current Version
object.
[System.Security.SecuritySafeCritical]
CompareTo(object version) Method
Compares the current Version
object to another object and returns an integer that indicates whether the current object precedes, follows, or occurs in the same position in sort order as the compared object.
CompareTo(Version value) Method
Compares the current Version
object to another Version
object and returns an integer that indicates whether the current object precedes, follows, or occurs in the same position in sort order as the compared object.
Equals(object obj) Method
Determines whether the current Version
object is equal to another object.
Equals(Version obj) Method
Determines whether the current Version
object is equal to another Version
object.
GetHashCode() Method
Returns the hash code for the current Version
object.
Parse(string version) Method
Converts the specified string representation of a version number to its Version
equivalent.
[System.Security.SecuritySafeCritical]
op_Equality(Version left, Version right) Operator
Compares two Version
objects for equality.
op_Inequality(Version left, Version right) Operator
Compares two Version
objects for inequality.
op_GreaterThan(Version left, Version right) Operator
Compares two Version
objects to determine if the first is greater than the second.
op_GreaterThanOrEqual(Version left, Version right) Operator
Compares two Version
objects to determine if the first is greater than or equal to the second.
op_LessThan(Version left, Version right) Operator
Compares two Version
objects to determine if the first is less than the second.
op_LessThanOrEqual(Version left, Version right) Operator
Compares two Version
objects to determine if the first is less than or equal to the second.
ToString() Method
Returns a string representation of the current Version
object.
ToString(int fieldCount) Method
Returns a string representation of the current Version
object, using the specified number of components.
[System.Security.SecuritySafeCritical]
TryParse(string version, out Version result) Method
Tries to convert the string representation of a version number to its Version
equivalent. Returns true if the conversion is successful; otherwise, false.
[System.Security.SecuritySafeCritical]
TryParse(string version, System.Globalization.NumberStyles styles, System.IFormatProvider provider, out Version result) Method
Tries to convert the string representation of a version number to its Version
equivalent using specified styles and format provider. Returns true if the conversion is successful; otherwise, false.
[System.Security.SecuritySafeCritical]