Returns this string right-aligned in a specified field width and padded with a specified character as needed.
[Visual Basic] Overloads Public Function PadRight( _ ByVal totalWidth As Integer, _ ByVal paddingChar As Char _ ) As String [C#] public string PadRight( int totalWidth, char paddingChar ); [C++] public: String* PadRight( int totalWidth, __wchar_t paddingChar ); [JScript] public function PadRight( totalWidth : int, paddingChar : Char ) : String;
This string is a right-aligned justified field width, padded with the specified character as needed.
Exception Type | Condition |
---|---|
ArgumentException | If the field width is less than zero. |
The PadRight method this instance of string aligned from the right and with padding charcters to make it the specified string length. If the field width is less than this string's length, the string is returned unaltered.
Managed C++
String *foo = L"forty-two";Console::Write(L"|"); Console::Write(foo->PadRight(25, L'.'));Console::WriteLine(L"|"); Console::Write(L"|");Console::Write(foo->PadRight(5, L'.')); Console::WriteLine(L"|"); Visual Basic Dim foo As String Dim bar As Char foo = "forty-two" bar = Convert.ToChar(".") 'Must do Char assignment in this round-about way for now since 'assignment of a character literal to a Char (e.g. bar = "."C) 'has not yet been implemented in VB. Console.WriteLine(foo.PadLeft(15, bar)) Console.WriteLine(foo.PadLeft(2, bar))
String Class | String Members | System Namespace | String.PadRight Overload List | Char | Int32