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;
This string as left-aligned field width with padded spaces using the specified character as needed.
Exception Type | Condition |
---|---|
ArgumentException | If the field width is less than zero. |
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.
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))
String Class | String Members | System Namespace | String.PadLeft Overload List | Char | Int32