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?
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?
Int values cannot have leading zeros
Although this is a old thread, but this can also help:
//D
represents 'Decimal', and 5 is the specified amount of digits you want the number to be always. This will pad your value with zeroes until it reaches 5 digits.you cant, but if you need to cast it to int and keep the zeros you can create a copy of it and then cast it to int, then you will have two versions of it one as int and one as string.
No,
int.Parse("09999")
actually returns 0x0000270F. Exactly 32 bits (because that's how bigint
is), 18 of which are leading zeros (to be precise, one is a sign bit, you could argue there are only 17 leading zeros).It's only when you convert it back to a string that you get "9999", presence or absence of the leading zero in said string is controlled by the conversion back to string.