Gunnar Peipman's ASP.NET blog

ASP.NET, C#, SharePoint, SQL Server and general software development topics.

Sponsors

News

 
 
 
 
 
Programming Blogs - Blog Catalog Blog Directory
 
 
 

Links

Social

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.

 

Posted: Apr 03 2008, 02:41 AM by DigiMortal | with 2 comment(s)
Filed under: ,

Comments

ca8msm said:

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:

aspnetlibrary.com/articledetails.aspx

# April 3, 2008 5:22 AM

Gunnar Peipman's ASP.NET blog said:

During one SharePoint migration project I had problem with document versions comments. I needed some

# April 5, 2008 3:25 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)