BCL mscorlib [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ] 1.0.5000.0 2.0.0.0 4.0.0.0 All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe. System.Object System.ICloneable System.IComparable System.IComparable<System.Version> System.IEquatable<System.Version> System.Runtime.InteropServices.ComVisible(true)

Version numbers consist of two to four components: major, minor, build, and revision. The major and minor components are required; the build and revision components are optional, but the build component is required if the revision component is defined. All defined components must be integers greater than or equal to 0. The format of the version number is as follows (optional components are shown in square brackets ([ and ]):

major.minor[.build[.revision]]

The components are used by convention as follows:

Major: Assemblies with the same name but different major versions are not interchangeable. A higher version number might indicate a major rewrite of a product where backward compatibility cannot be assumed.

Minor: If the name and major version number on two assemblies are the same, but the minor version number is different, this indicates significant enhancement with the intention of backward compatibility. This higher minor version number might indicate a point release of a product or a fully backward-compatible new version of a product.

Build: A difference in build number represents a recompilation of the same source. Different build numbers might be used when the processor, platform, or compiler changes.

Revision: Assemblies with the same name, major, and minor version numbers but different revisions are intended to be fully interchangeable. A higher revision number might be used in a build that fixes a security hole in a previously released assembly.

Subsequent versions of an assembly that differ only by build or revision numbers are considered to be Hotfix updates of the prior version.

Starting with .NET Framework 2.0, the and properties enable you to identify a temporary version of your application that, for example, corrects a problem until you can release a permanent solution. Furthermore, the Windows NT operating system uses the property to encode the service pack number.

## Assigning Version Information to Assemblies

Ordinarily, the class is not used to assign a version number to an assembly. Instead, the class is used to define an assembly's version, as illustrated by the example in this topic.

## Retrieving Version Information

objects are most frequently used to store version information about some system or application component (such as the operating system), the common language runtime, the current application's executable, or a particular assembly. The following examples illustrate some of the most common scenarios:

Retrieving the operating system version. The following example uses the property to retrieve the version number of the operating system.

code reference: System.Version.Class#1

Retrieving the version of the common language runtime. The following example uses the property to retrieve version information about the common language runtime.

code reference: System.Version.Class#2

Retrieving the current application's assembly version. The following example uses the method to obtain a reference to an object that represents the application executable and then retrieves its assembly version number.

code reference: System.Version.Class#5

Retrieving the current assembly's assembly version. The following example uses the method to obtain a reference to an object that represents the current assembly and then retrieves its version information.

code reference: System.Version.Class#4

Retrieving the version of a specific assembly. The following example uses the method to obtain a reference to an object that has a particular file name, and then retrieves its version information. Note that several other methods also exist to instantiate an object by file name or by strong name.

code reference: System.Version.Class#3

Retrieving the Publish Version of a ClickOnce application. The following example uses the property to display an application's Publish Version. Note that its successful execution requires the example's application identity to be set. This is handled automatically by the Visual Studio Publish Wizard.

code reference: System.Version.Class#7

The Publish Version of an application for ClickOnce deployment is completely independent of its assembly version.

## Comparing Version Objects

You can use the method to determine whether one object is earlier than, the same as, or later than a second object. The following example indicates that Version 2.1 is later than Version 2.0.

code reference: System.Version.Class.Comparing#1

For two versions to be equal, the major, minor, build, and revision numbers of the first object must be identical to those of the second object. If the build or revision number of a object is undefined, that object is considered to be earlier than a object whose build or revision number is equal to zero. The following example illustrates this by comparing three objects that have undefined version components.

code reference: System.Version.Class.Comparing#2

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

- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  and are set to zero. and are unspecified.

  Initializes a new instance of the class.

  0
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  has fewer than 2 components or more than 4 components (i.e. fewer than 1 or more than 3 period characters).
  is a null reference.
  , , , or is less than zero.
  At least one component of does not parse to a with ().

  The following example sets the version to "6.1.2.4" and writes the result to the console.

  using System;

  public class Vers { public static void Main() {

  Version vers = new Version( "6.1.2.4" ); Console.WriteLine( "Version is {0}", vers.ToString() ); } }

  The output is

  Version is 6.1.2.4

  The parameter can contain only the components major, minor, build, and revision, in that order, and all separated by periods. There must be at least two components, and at most four. The first two components are assumed to be major and minor. The value of unspecified components is undefined.

  The format of the version number is as follows. Optional components are shown in square brackets ('[' and ']'):

  major.minor[.build[.revision]]

  All defined components must be integers greater than or equal to 0. For example, if the major number is 6, the minor number is 2, the build number is 1, and the revision number is 3, then should be "6.2.1.3".

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

  A string containing the major, minor, build, and revision numbers, where each number is delimited with a period character ('.').
  0
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  To be added.
  or is less than zero.

  The following example sets the version to "6.1" and writes the result to the console.

  using System;

  public class Vers { public static void Main() {

  Version vers = new Version( 6, 1 ); Console.WriteLine( "Version is {0}", vers.ToString() ); } }

  The output is

  Version is 6.1

  The major version number.
  The minor version number.

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

  The major version number.
  The minor version number.
  0
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  To be added.
  , , or is less than zero.

  The following example sets the version to "6.1.2" and writes the result to the console.

  using System;

  public class Vers { public static void Main() {

  Version vers = new Version( 6, 1, 2 ); Console.WriteLine( "Version is {0}", vers.ToString() ); } }

  The output is

  Version is 6.1.2

  The major version number.
  The minor version number.
  The build number.

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

  The major version number.
  The minor version number.
  The build number.
  0
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  To be added.
  , , , or is less than zero.

  The following example sets the version to "6.1.2.4" and writes the result to the console.

  using System;

  public class Vers { public static void Main() {

  Version vers = new Version( 6, 1, 2, 4 ); Console.WriteLine( "Version is {0}", vers.ToString() ); } }

  The output is

  Version is 6.1.2.4

  The major version number.
  The minor version number.
  The build number.
  The revision number.

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

  The major version number.
  The minor version number.
  The build number.
  The revision number.
  0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32

  A specifying the build component, or -1 if the build component is undefined.

  `using System; class VersionBuildExample { public static void Main() { Version vers = new Version("6.1.2.4"); Console.Write("The build component of "); Console.WriteLine("version vers = {0}.", vers.Build); } }`

  The output is

  The build component of version vers = 2.

  For example, if the version number is 6.2.1.3, the build number is 1. If the version number is 6.2, the build number is undefined.

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

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Object

  The following example clones the version number and writes the result to the console.

  `using System; class VersionCloneExample { public static void Main() { Version vers = new Version("6.1.2.4"); Console.WriteLine("The string representation of the" + " version is {0}.", vers.ToString()); Version clone = (Version) vers.Clone(); Console.WriteLine("The original version was" + " successfully cloned."); Console.Write("The string representation of the" + " cloned version is {0}.", clone.ToString()); } }`

  The output is

  The string representation of the version is 6.1.2.4.

  The original version was successfully cloned.

  The string representation of the cloned version is 6.1.2.4.

  If the type of the return value is important, cast the instance that is returned by this method to a object.

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

  A new whose values are a copy of the current object.

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 `` is not a and is not a null reference `using System; class VersionTest { static string Test ( Version v1, Version v2 ) { int i = v1.CompareTo(v2); if ( i < 0 ) return "older than"; else if ( i == 0 ) return "the same as"; else return "newer than"; } public static void Main() { Version vers1 = new Version( "6.1.2.4" ); Version vers2 = new Version( 6, 1 ); Version vers3 = new Version( 6, 1, 3 ); Console.Write("Version {0} is {1} ", vers1, Test(vers1, vers2)); Console.WriteLine("version {0}", vers2); Console.Write("Version {0} is {1} ", vers1, Test(vers1, vers3)); Console.WriteLine("version {0}", vers3); Console.Write("Version {0} is {1} ", vers3, Test(vers3, vers3)); Console.WriteLine("version {0}", vers3); Console.Write("Version {0} is {1} ", vers2, Test(vers2, vers1)); Console.WriteLine("version {0}", vers1); } }`

  The output is

  Version 6.1.2.4 is newer than version 6.1

  Version 6.1.2.4 is older than version 6.1.3

  Version 6.1.3 is the same as version 6.1.3

  Version 6.1 is older than version 6.1.2.4

  The components of Version in decreasing order of importance are: major, minor, build, and revision. An unknown component is assumed to be older than any known component.

  For example:

  Version 1.1 is older than version 1.1.0

  Version 1.1 is older than version 1.1.1

  Version 1.1 is older than version 1.1.2.3

  Version 1.1.2 is older than version 1.1.2.4

  Version 1.2.5 is newer than version 1.2.3.4

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

  A signed integer that indicates the relative values of the two objects, as shown in the following table.

  Return value

  Meaning

  Less than zero

  The current object is a version before .

  Zero

  The current object is the same version as .

  Greater than zero

  The current object is a version subsequent to .

  -or-

  is null.

  An object to compare, or null. 0
- Method
  2.0.0.0
  4.0.0.0
  System.Int32 ``

  This method implements the interface, and performs slightly better than the method because it does not have to unbox the parameter.

  The components of Version in decreasing order of importance are: major, minor, build, and revision. An unknown component is assumed to be older than any known component. For example:

  Version 1.1 is older than version 1.1.0.

  Version 1.1 is older than version 1.1.1.

  Version 1.1 is older than version 1.1.2.3.

  Version 1.1.2 is older than version 1.1.2.4.

  Version 1.2.5 is newer than version 1.2.3.4.

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

  A signed integer that indicates the relative values of the two objects, as shown in the following table.

  Return value

  Meaning

  Less than zero

  The current object is a version before .

  Zero

  The current object is the same version as .

  Greater than zero

  The current object is a version subsequent to .

  -or-

  is null.

  A object to compare to the current object, or null.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean ``

  This method overrides .

  `using System; class VersionEqualsExample { static void testEquals(Version v1, Version v2) { Console.Write("It is {0} that version ", v1.Equals(v2)); Console.WriteLine("{0} is equal to {1}.", v1, v2); } public static void Main() { Version vers1 = new Version( "6.1.2.4" ); Version vers2 = new Version( 6, 1 ); testEquals( vers1, vers1 ); testEquals( vers1, vers2 ); } }`

  The output is

  It is True that version 6.1.2.4 is equal to 6.1.2.4.

  It is False that version 6.1.2.4 is equal to 6.1.

  An object to compare with the current object, or null.

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

  true if the current object and are both objects, and every component of the current object matches the corresponding component of ; otherwise, false.

  An object to compare with the current object, or null. 0
- Method
  2.0.0.0
  4.0.0.0
  System.Boolean ``

  This method implements the interface, and performs slightly better than the method because it does not have to unbox the parameter.

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

  true if every component of the current object matches the corresponding component of the parameter; otherwise, false.

  A object to compare to the current object, or null.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32

  The algorithm used to generate the hash code is unspecified.

  This method overrides .

  Returns a hash code for the current object.

  A 32-bit signed integer hash code.

  0
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32

  A specifying the major component.

  `using System; class VersionMajorExample { public static void Main() { Version vers = new Version("6.1.2.4"); Console.Write("The major component "); Console.WriteLine("of version vers = {0}.", vers.Major); } }`

  The output is

  The major component of version vers = 6.

  For example, if the version number is 6.2, the major version is 6.

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

  0
- Property
  2.0.0.0
  4.0.0.0
  System.Int16 To be added.

  Suppose you release an interim version of your application to temporarily correct a problem until you can release a permanent solution. The temporary version does not warrant a new revision number, but it does need to be identified as a different version. In this case, encode the identification information in the high and low 16-bit portions of the 32-bit revision number. Use the property to obtain the entire revision number, use the property to obtain the high 16 bits, and use the property to obtain the low 16 bits.

  Starting in the .NET Framework version 2.0, the Windows NT operating system uses the property to encode the service pack number.

  Gets the high 16 bits of the revision number.

- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32

  A specifying the minor component.

  `using System; class VersionMinorExample { public static void Main() { Version vers = new Version("6.1.2.4"); Console.Write("The minor component "); Console.WriteLine("of version vers = {0}.", vers.Minor); } }`

  The output is

  The minor component of version vers = 1.

  For example, if the version number is 6.2, the minor version is 2.

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

  0
- Property
  2.0.0.0
  4.0.0.0
  System.Int16 To be added.

  Suppose you release an interim version of your application to temporarily correct a problem until you can release a permanent solution. The temporary version does not warrant a new revision number, but it does need to be identified as a different version. In this case, encode the identification information in the high and low 16-bit portions of the 32-bit revision number. Use the property to obtain the entire revision number, use the property to obtain the high 16 bits, and use the property to obtain the low 16 bits.

  Gets the low 16 bits of the revision number.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean `` ``

  The parts of the version number are compared independently starting with the property and then the , , and properties, in order. This method returns as soon as one of the properties is determined not to be equal.

  Determines whether two specified objects are equal.

  true if equals ; otherwise, false.

  The first object. The second object. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean `` ``

  The parts of the version number are compared independently starting with the property and then the , , and properties, in order. This method returns as soon as one of the properties is determined not to be equal.

  is a reference.

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

  true if is greater than ; otherwise, false.

  The first object. The second object. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean `` ``

  The parts of the version number are compared independently starting with the property and then the , , and properties, in order. This method returns as soon as one of the properties is determined not to be equal.

  is a reference.

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

  true if is greater than or equal to ; otherwise, false.

  The first object. The second object. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean `` ``

  The parts of the version number are compared independently starting with the property and then the , , and properties, in order. This method returns as soon as one of the properties is determined not to be equal.

  Determines whether two specified objects are not equal.

  true if does not equal ; otherwise, false.

  The first object. The second object. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean `` ``

  The parts of the version number are compared independently starting with the property and then the , , and properties, in order. This method returns as soon as one of the properties is determined not to be equal.

  is a reference.

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

  true if is less than ; otherwise, false.

  The first object. The second object. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean `` ``

  The parts of the version number are compared independently starting with the property and then the , , and properties, in order. This method returns as soon as one of the properties is determined not to be equal.

  is a reference.

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

  true if is less than or equal to ; otherwise, false.

  The first object. The second object. 0
- Method
  4.0.0.0
  System.Version ``

  The parameter must have the following format:

  `major.minor[.build[.revision]]`

  where major, minor, build, and revision are the string representations of the version number's four components: major version number, minor version number, build number, and revision number. Optional components are shown in square brackets ([ and ]). The components must appear in the specified order, and must be separated by periods.

  Because the string representation of a version number must conform to a recognized pattern, applications should always use exception handling when calling the method to parse user input. Alternatively, you can call the method to parse the string representation of a version number and return a value that indicates whether the parse operation succeeded.

  The method is a convenience method; it is equivalent to calling the constructor.

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

  An object that is equivalent to the version number specified in the parameter.

  A string that contains a version number to convert.
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32

  A specifying the revision component, or -1 if the revision component is undefined.

  `using System; class VersionRevisionExample { public static void Main() { Version vers = new Version("6.1.2.4"); Console.Write("The revision component of "); Console.WriteLine("version vers = {0}.", vers.Revision); } }`

  The output is

  The revision component of version vers = 4.

  For example, if the version number is 6.2.1.3, the revision number is 3. If the version number is 6.2, the revision number is undefined.

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

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String To be added.

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

  The representation of the values of the major, minor, build, and revision components of the current 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 object using the constructor Version(1,1), the returned string is "1.1". If you create a object using the constructor Version(1,3,4,2), the returned string is "1.3.4.2".

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String `` To be added.

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

  The representation of the values of the major, minor, build, and revision components of the current object, each separated by a period character ('.'). The parameter determines how many components are returned.

  fieldCount

  Return Value

  0

  An empty string ("").

  1

  major

  2

  major.minor

  3

  major.minor.build

  4

  major.minor.build.revision

  For example, if you create object using the constructor Version(1,3,5), ToString(2) returns "1.3" and ToString(4) throws an exception.

  The number of components to return. The ranges from 0 to 4.
- Method
  4.0.0.0
  System.Boolean `` `` To be added. To be added. To be added. To be added. To be added.
0