C# Version Parse

Description

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

Syntax

Version.Parse has the following syntax.


public static Version Parse(
  string input
)

Parameters

Version.Parse has the following parameters.

  • input - A string that contains a version number to convert.

Returns

Version.Parse method returns An object that is equivalent to the version number specified in the input parameter.

Example

The following example uses the Parse method to parse a number of strings that contain version information.


//from   w ww .  j  a va 2s . c o m
using System;

public class Example
{
   public static void Main()
   {
      string input = "4.0";
      Version ver = Version.Parse(input);
      Console.WriteLine(ver);

      input = "4.0.";
      ver = Version.Parse(input);
      Console.WriteLine(ver);

      input = "1.1.2";
      ver = Version.Parse(input);
      Console.WriteLine(ver);

   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version