I want to compare versions that contains both number and alphabet in C#. For example, version 1.1.1b is a newer version compare to 1.1.1a. Is there a way to compare the '1b' and '1a' so that 1b is the newer version? Thanks.
Asked
Active
Viewed 176 times
0
-
as long as you can limit it to ASCII characters, you can rely on the alphabetical order of char values: char 'b' is greater than 'a'. It gets difficult with "10a" and "9a", here the second will be greater if you compare char values ('9' > '1' is true), so you need to implement an `IComparer`/`IComparable` that splits numeric and alpha parts internally, and compares separately, like 1.1.10.b and 1.1.9.b – Cee McSharpface Jun 08 '17 at 17:20
-
Thanks, I will try it out. – Kelvin Jun 08 '17 at 17:40