string class : PadStart(int) method
Description
It returns a new string that is added blanks of the specified length to the top of the caller string.
Syntax
stringInstance.PadStart(int length)
Arguments
Class | Name | Description |
int | length | The length of the blanks to be added to the top. |
Return value
Class | Description |
string | A new string that is added blanks of the specified length to the top of the caller string. |
Sample code
1: | string str = "sample string"; |
2: | string newString = str.PadStart(5); // The result (newString) is " sample string". |
Notes
An UnknownException (ArgumentOutOfRangeException) is thrown if you specify a value less than zero for the argument.
Links for reference
None.