Syntax
string string.PadRight(int totalWidth);
Program
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string str = "Hello world";
Console.WriteLine("Demonstration of PadRight method");
Console.WriteLine(str.PadRight(str.Length + 1) + "##########");
Console.WriteLine(str.PadRight(str.Length + 2) + "##########");
Console.WriteLine(str.PadRight(str.Length + 3) + "##########");
Console.WriteLine(str.PadRight(str.Length + 4) + "##########");
Console.WriteLine(str.PadRight(str.Length + 5) + "##########");
Console.WriteLine();
}
}
}
Output
Demonstration of PadRight method
Hello world ##########
Hello world ##########
Hello world ##########
Hello world ##########
Hello world ##########