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.PadLeft (Int32, Char)

Returns this string left-aligned in a field and padded with the specified padding character as needed.

[Visual Basic]
Overloads Public Function PadLeft( _
   ByVal totalWidth As Integer, _
   ByVal paddingChar As Char _
) As String
[C#]
public string PadLeft(
   int totalWidth,
   char paddingChar
);
[C++]
public: String* PadLeft(
   int totalWidth,
   __wchar_t paddingChar
);
[JScript]
public function PadLeft(
   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 as left-aligned field width with padded spaces using the specified character as needed.

Exceptions

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

Remarks

The PadLeft method this instance of string aligned from the left and with padding charcters to make it the specified string length. If the field width is less than the string's length, the string is returned unaltered.

Example

Managed C++:

String *foo
= L"forty-two";
Console::WriteLine(foo->PadLeft(15,
L'.'));
Console::WriteLine(foo->PadLeft(2,
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.PadLeft Overload List | Char | Int32