I am trying to format some c# output so that a number always has 2 digits for instance if int = 0 i would like Console.WriteLine(int); to produce 00.
I am trying to format some c# output so that a number always has
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Take a look at http://msdn.microsoft.com/en-us/library/0c899ak8.aspx
This should do what you want:
The string that is passed to the ToString method “0#” has the following meaning:
So if num is 0, 00 will be written to the console but if num is 10, 10 will be written to the console.