If your string has at most 4 numeric parts (separated by a character . ), You can use the Version class to get a strongly typed object that matches these strings. Version implements various comparison operators ( == , > , < , etc.) in the expected mode, so you can find out more:
var a = new Version(A); var b = new Version(B); if(a > b)
If there are more than 4 parts, you need to divide each line into numeric components, convert them to the numerical equivalent and compare the two resulting collections.
Sort of:
var aParts = A.Split('.'); var bParts = B.Split('.'); // assumes the string have the same number of parts for(int i = 0; i < aParts.Length; i++) { var currA = int.Parse(aParts[i]); var currB = int.Parse(bParts[i]); if(currA == currB) continue; if(currA > currB) // A is greater than B else // B is greater than A }
Odded source share