How to compare if "1.20.0" is greater then "1.3.10"? [CS/C# 2003]

Shaitan00

Junior Contributor
Joined
Aug 11, 2003
Messages
358
Location
Hell
I have 2 strings (sOldVersion & sNewVersion) that have the form xxx.xxx.xxx (3 sections) ... for example:
1.2.3
1.10.33
2.1.15
7.80.1
These correspond to VERSIONS of one of our components (and they are retireved a strings in-code).
My problem is I need to determine if "sNewVersion" is greater, equal, or less then "sOlderVersion" ... and I can't just cast these as integers (obviouslly)...

Anyone have a clue how I could accomplish such a comparaison?
One solution I thought of (but have not yet implemented) would be to break down each version section (high, med, low), cast them as integers, and compare like that (I am sure I can get it to work, but is there a nicer way to do this?)

Any help, hints, or ideas would be greatly appreciated.
Thanks,
 
Give Version a try.
Code:
        Dim v1 As New Version("1.10.33")
        Dim v2 As New Version("1.2.3")

        Debug.WriteLine(v1.CompareTo(v2))
 
Back
Top