Padding a string to a fixed length
suggest changestring s = "Foo";
string paddedLeft = s.PadLeft(5); // paddedLeft = " Foo" (pads with spaces by default)
string paddedRight = s.PadRight(6, '+'); // paddedRight = "Foo+++"
string noPadded = s.PadLeft(2); // noPadded = "Foo" (original string is never shortened)
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents