C#StringPadLeft

Returns a right-aligned string padded on the left.

Syntax

str.PadLeft(totalWidth, paddingChar?)

Example

Enter values below to update the example in real time.

string
code
Console
WriteLine
PadLeft
string code = "42";
Console.WriteLine(code.PadLeft(5, '0'));   // "00042"