PadLeft and PadRight

The PadLeft and PadRight options endeavor to make a string up to a maximum length. Both PadLeft and PadRight take the same arguments as follows:

PS> ''.PadRight
''.PadLeft

OverloadDefinitions
-------------------
string PadRight(int totalWidth)
string PadRight(int totalWidth, char paddingChar)

string PadLeft(int totalWidth)
string PadLeft(int totalWidth, char paddingChar)

Each method attempts to make a string up to the total width. If the string is already equal to, or longer than the total width, it will not be changed. Unless another is supplied, the padding character is a space.

The following example pads the right-hand side of strings using '.' as the padding character argument:

PS> ('one', 'two', 'three').PadRight(10, '.')

one.......
two.......
three.....

Padding a string on the left, in effect, right justifies the string:

PS> ('one', 'two', 'three').PadLeft(10, '.')

.......one
.......two
.....three
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.206.254