# Using Version Class

When dealing with version numbers we often need to convert them to string and vice versa. There is lot of code where versions are handled manually in code. I don’t know why. But I know for sure there is class called Version and I’m sure this class will help us a lot. Let’s see a little example.

The following code:

Version ver = new Version("1.4");Console.WriteLine("Major: " + ver.Major.ToString());Console.WriteLine("Minor: " + ver.Minor.ToString());Console.WriteLine("String: " + ver.ToString());Console.ReadLine();

outputs something like this:

Major: 1 Minor: 4

String: 1.4

As we can see, this class makes using versions very easy. There is one nasty limitation – Version class is sealed. If there is need for non-sealed class then you should write it by yourself.

### 3 thoughts on “Using Version Class”

• ca8msm says:

You can also control the version numbers and other information (such as title, description etc) via an AssemblyInfo file. See my article on it here for a method of accessing this file:

http://aspnetlibrary.com/articledetails.aspx

• […] thing is class called Version. I wrote about it blog entry Using Version Class. As Version is sealed class we are not able to extend it. But we can always use extension methods […]

• […] Click here to go to article […]