Padding character in string
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Padding
{
class Program
{
static void Main(string[] args)
{
string str = "This is a text";
char padChar = '.';
Console.WriteLine(str.PadLeft(25, padChar));
Console.WriteLine(str.PadLeft(2, padChar));
Console.WriteLine(str.PadRight(25, padChar));
Console.WriteLine(str.PadRight(2, padChar));
str = "I am Mahedee hasan. Software Architect, Leadsoft Bangladesh Ltd";
Console.WriteLine((str.PadRight(25, padChar)));
Console.WriteLine((str.PadRight(25,padChar)).Substring(0,24)+"...");
Console.ReadKey();
}
}
}
Output:
...........This is a text
This is a text
This is a text...........
This is a text
I am Mahedee hasan. Software Architect, Leadsoft Bangladesh Ltd
I am Mahedee hasan. Soft...