StringFunctions.

PadRight(string, int, string) Method

Summary

Returns the given string right-padded to the given length.
Assembly
NAnt.Core.dll
Namespace
NAnt.Core.Functions
Containing Type
StringFunctions

Syntax

[Function("pad-right")]
public static string PadRight(string s, int totalWidth, string paddingChar)

Examples

string::pad-right('test', 10, ' ') ==> 'test      '
string::pad-right('test', 10, 'abcd') ==> 'testaaaaaa'
string::pad-right('test', 3, ' ') ==> 'test'
string::pad-right('test', -3, ' ') ==> ERROR

Remarks

Note that only the first character of paddingChar will be used when padding the result.

Attributes

Type Description
FunctionAttribute Indicates that the method should be exposed as a function in NAnt build files.

Parameters

Name Type Description
s string The string that needs to be right-padded.
totalWidth int The number of characters in the resulting string, equal to the number of original characters plus any additional padding characters.
paddingChar string A Unicode padding character.

Return Value

Type Description
string If the length of s is at least totalWidth, then a new string identical to s is returned. Otherwise, s will be padded on the right with as many paddingChar characters as needed to create a length of totalWidth.