To pad a string to a certain length, we can use the PadLeft and PadRight methods of the String class.
String.PadLeft Method (Int32)
String.PadLeft Method (Int32, Char)
String.PadRight Method (Int32)
String.PadRight Method (Int32, Char)
For example:
myString = “123”.PadLeft(6, “0”c)
will return “000123”.
Right-aligns the characters in this instance, padding on the left with a specified Unicode character for a specified total length.