Padding a string to a fixed length

suggest change
string 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)

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents