c# - toString() of int e = 0000007 omits all zeros. How can I preserve them? -


I am trying to write a program in c # which takes it in int x and decides whether He has 7 points. Right now I am using x.toString (). To check the length == 7, but I have noticed that if the number starts with 0, then it is automatically dropped and I get an incorrect answer (i.e. the program input length is less than 7)

Is there a way to fix this? thank you in advanced.

Edit: Sorry, I should have said that this was a program to collect and validate the format of ID numbers (hence I did not want to do anything like 0000001 default for 1) Thanks string Input suggestion, I think I'm going to try.

If you want to preserve the input formatting, you should input the int You should not store it in string .

You say that your program takes a int at that time you have already lost it. You need to accept the interface string input is.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -