NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

String.PadRight (Int32, Char)

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;

Parameters

totalWidth
The field width to justify in this string.
paddingChar
The character used to pad.

Return Value

This string is a right-aligned justified field width, padded with the specified character as needed.

Exceptions

Exception Type Condition
ArgumentException If the field width is less than zero.

Remarks

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.

Example

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))

See Also

String Class | String Members | System Namespace | String.PadRight Overload List | Char | Int32