PadLeft/PadRight is padding on the left/Right with spaces or a specified Unicode character for a specified total length.
Example as bellow:
string myString = "";
int myInt = 1;
myString = myInt.ToString().PadLeft(8, '0');
//myString will be 00000001
myString = myInt.ToString().PadRight(8, '0');
//myString will be 10000000
No comments:
Post a Comment