System Namespace String Class
Left-aligns the characters in this string, padding on the right with spaces or a specified Unicode character, for a specified total length.
1. Left-aligns the characters in this string, padding with spaces on the right, for a specified total length.
2. Left-aligns the characters in this string, padding on the right with a specified Unicode character, for a specified total length.
NOTE: This example shows how to use one of the overloaded versions of PadRight. For other examples that might be available, see the individual overload topics.
[ 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