Pad the end of the string with spaces using the PadRight() method. You can also pad it with a Unicode character.
Let’s say the following is our string.
string myStr = "Text1";
To set a padding at the end of the above string, use the PadRight method.
myStr.PadRight(10);
Here is the complete example.
Example
using System;
class Demo {
static void Main() {
string myStr = "Text1";
// set padding at the end
Console.Write(myStr.PadRight(10));
Console.WriteLine("Text2");
}
}Output
Text1 Text2