String.PadRight Method
.NET Framework 1.1
Left-aligns the characters in this string, padding on the right with spaces or a specified Unicode character, for a specified total length.
Overload List
Left-aligns the characters in this string, padding with spaces on the right, for a specified total length.
Supported by the .NET Compact Framework.
[Visual Basic] Overloads Public Function PadRight(Integer) As String
[C#] public string PadRight(int);
[C++] public: String* PadRight(int);
[JScript] public function PadRight(int) : String;
Left-aligns the characters in this string, padding on the right with a specified Unicode character, for a specified total length.
Supported by the .NET Compact Framework.
[Visual Basic] Overloads Public Function PadRight(Integer, Char) As String
[C#] public string PadRight(int, char);
[C++] public: String* PadRight(int, __wchar_t);
[JScript] public function PadRight(int, Char) : String;
Example
[Visual Basic, C++, JScript] The following code example demonstrates the PadRight method.
[Visual Basic, C++, JScript] 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.
[Visual Basic] Dim str As String Dim pad As Char str = "forty-two" pad = Convert.ToChar(".") Console.WriteLine(str.PadRight(15, pad)) ' Displays "|forty-two......|". Console.WriteLine(str.PadRight(2, pad)) ' 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 = "."; Console.WriteLine(str.PadRight(15, pad)); // Displays "|forty-two......|". Console.WriteLine(str.PadRight(2, pad)); // Displays "|forty-two|".
[C#] No example is available for C#. To view a Visual Basic, C++, or JScript example, click the Language Filter button
in the upper-left corner of the page.