Question

I need to parse a number with leading zeros:

if (uint.TryParse(strNum, NumberStyles.Integer, CultureInfo.InvariantCulture, out num))

returns false Whats is correct way to get number?Use other NumberStyles?Which?

The strNum is 01101250000000012300695162716

Was it helpful?

Solution

Cannot convert that string to an uint, try with a decimal

decimal num;
string strNum = "01101250000000012300695162716";
if (decimal.TryParse(strNum, NumberStyles.Any, CultureInfo.InvariantCulture, out num))
    Console.WriteLine(num.ToString());

The uint.MaxValue is defined as "4,294,967,295", your conversion fails for this reason

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top