I have two strings:
var Number1 = "1CDDE";
var Number2 = "01CDDE";
The length of the numbers are fixed, six characters.
I have to compare these numbers without leading zeroes. Should I remove the first zero or add zeroes if a length of a numbers is less than six?
No problem, if the value is int, but when I try to make something like this with strings (parse to int, for example or pass in String.Format), I can’t do it.
What is the solution?
Use
string.TrimStartto remove the leading zeroes if you have no control over them, or standardize on an approach (either always or never include leading zeroes) if you do.For example: