I have a document management system where documents can have multiple versions. Each version is saved and users can view version history.
What I would like to know is: What datatype should I use for version numbers? Decimal, Float or Double? I'm using .NET and C#.
Version numbers start at 0.1 and each published major version will be rounded to the next whole number. i.e. 0.4 goes to 1.0 and 1.3 goes to 2.0 etc.
When a version numbers hits 0.9 and a minor version is added I would like the number to go to 0.10 not 1.0, when I add to it. This is the biggest issue.
Any suggestions are appreciated.
Thanks.
System.Version
This already stores the different parts, deals with presenting it as a string (revision and build components are only used in display if they are non-zero, so their irrelevance to your case doesn't matter) and (best of all) is already understood by other .NET developers, and won't lead to confusion (if I saw some use of a version number that wasn't a System.Version
I'd spend some time then trying to work out why Version
wasn't good enough for the job, in case that proved important and hid a nasty surprise. If it was good enough for the job, I'd be irritated at the developer wasting my time like that).
You can deal with the means you want for incrementing easily with extension methods:
public static Version IncrementMajor(this Version ver)
{
return new Version(ver.Major + 1, 0);
}
public static Version IncrementMinor(this Version ver)
{
return new Version(ver.Major, ver.Minor + 1);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With