System Namespace String Class
Left-aligns the characters in this string, padding on the right with a specified Unicode character, for a specified total length.
[ VB ]
<Serializable>
Overloads Public Function PadRight ( _
ByVal totalWidth As Integer, _
ByVal paddingChar As Char _
) As String
[ C# ]
[ Serializable ]
public string PadRight (
int totalWidth,
char paddingChar
);
[ C++ ]
[ Serializable ]
public: String* PadRight (
int totalWidth,
__wchar_t paddingChar
);
[ JScript ]
public Serializable
function PadRight (
totalWidth : int,
paddingChar : Char
) : String;
- totalWidth
- The number of characters in the resulting string, equal to the number of original characters plus any additional padding characters.
- paddingChar
- A Unicode padding character.
A new String that is equivalent to this instance, but left-aligned and padded on the right with as many paddingChar characters as needed to create a length of totalWidth.
-or-
If totalWidth is less than the length of this instance, a new String that is identical to this instance.
[ VB ]
Dim str As String
Dim bar As Char
str = "forty-two"
bar = Convert.ToChar ( "." )
Response.WriteLine ( str.PadRight ( 15, bar ) ) ' Displays "|forty-two......|".
Response.WriteLine ( str.PadRight ( 2, bar ) ) ' Displays "|forty-two|".
[ C++ ]
String *str = L"forty-two";
Console::Write ( L"|" );
Console::Write ( str->PadRight ( 15, L'.' ) );
Console::WriteLine ( L"|" ); // Displays "|forty-two......|".
Console::Write ( L"|" );
Console::Write ( str->PadRight ( 5, L'.' ) );
Console::WriteLine ( L"|" ); // Displays "|forty-two|".
[ JScript ]
var str : String = "forty-two";
var pad : char = ".";
Response.WriteLine ( str.PadRight ( 15, pad ) ); // Displays "|forty-two......|".
Response.WriteLine ( str.PadRight ( 2, pad ) ); // Displays "|forty-two|".
String Members String.PadRight Overload List Char Int32 PadLeft Trim