Converting string to int without losing the zero in the beginning

Viewed 30557

I tried int.parse, and convert class to convert a string to int.

While I'm converting. I'm losing the 0 in the beginning which i don't want.

Ex : 09999 becomes 9999 - I don't want this.

I want to keep it as it is.

How can i do that?

10 Answers

Although this is a old thread, but this can also help:

// convert to big integer
var bigIntBits = BigInteger.Parse(intNumber);
int indexOfOne = intNumber.IndexOf('1');            
string backToString = new string('0', indexOfOne) + bigIntBits.ToString();    
Related