Mono Class Library: System.Version Overview | Members

System.Version Constructor

Constructs and initializes a new instance of the Version class using the values represented by the specified string. [Edit]

public Version (string version)

Parameters

version

A string that represents 2 to 4 int integers separated by period characters ('.'). Each component delineated by a period character will be parsed to a int with int.Parse(string)(string). The numbers will be processed in the following order: major, minor, build, revision. If the revision or the revision and the build components are not represented by version, their values will be undefined.

Note:

The formatting of version must be as follows, with optional components shown in square brackets ('[' and']'): major.minor[.build[.revision]], where each component returns a int with int.Parse(string) (string).

[Edit]

Exceptions

TypeReason
ArgumentExceptionversion has fewer than 2 components or more than 4 components (i.e. fewer than 1 or more than 3 period characters). [Edit]
ArgumentNullExceptionversion is a null reference. [Edit]
ArgumentOutOfRangeExceptionmajor, minor, build, or revision is less than zero. [Edit]
FormatExceptionAt least one component of version does not parse to a int with int.Parse(string) (string). [Edit]

Remarks

Documentation for this section has not yet been entered. [Edit]

Example

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

C# Example
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

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0