If I have two numbers represented as strings, “100” and “200”, “100.1” and “200.1”, how can I compare them to see if they which one is bigger?
Is there a generic Number.Compare(stringA, stringB) that will take care of datatype? I am using a database entry to determine validation rules, but the values could be long, decimal, floats, etc, so I can’t create a single one.
No, there is no generic number comparison. You should know type of number. E.g. you can’t parse string with floating point number “100.1” as integer. I’d go with parsing your strings as decimals or doubles (which will handle both “100” and “100.1”), and then comparing results. Use Math.Max to get larger from two numbers: