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.
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
Pingback:SharePoint: Changing comments of document versions in code | Gunnar Peipman - Programming Blog