I need to add leading zeros to numbers which may be negative or positive. I am able to add them fine for positive numbers. How do I do the same for negative numbers?
For example:
int number1 = 1;
string pad1 = number1.ToString().PadLeft(3, '0');
//output 001
int number2 = -1;
string pad2 = number2.ToString().PadLeft(3, '0');
//output 0-1
//expected output -001
Tried using this... It works!
int number1 = 1;
string pad1 = number1.ToString("000");
//output 001
int number2 = -1;
string pad2 = number2.ToString("000");
//output -001