KazoWAR
January 15th, 2010, 11:39 PM
How would I write an integer to a desired number of places. For example, lets say int x = 50; Now, when I write x to a text box it displaces 50, but I want x to display 0050. I could do something simple like "00" + x, but when the number reaches the 100s or 1000s, I do not want the extra zeros.
Arjay
January 15th, 2010, 11:54 PM
http://msdn.microsoft.com/en-us/library/0c899ak8(VS.71).aspx
Mutant_Fruit
January 16th, 2010, 05:47 AM
// Convert 'number' to a string and ensure that it
// is at least 4 characters long by prepending it with
// zeros if it is shorter than 4.
int number = GetNumber ();
string result = number.ToString ().PadLeft (4, '0');