C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
C# String PadRight()The C# PadRight() method is used to get a new string that left-aligns the characters in this string by padding them with spaces on the right, for a specified total length. Signaturepublic string PadRight(Int32 length) public string PadRight(Int32, Char) Parameterlength: it is an integer type parameter. ReturnIt returns a string. C# String PadRight() Method Example
using System;
public class StringExample
{
public static void Main(string[] args)
{
string s1 = "Hello C#";// 8 length of characters
string s2 = s1.PadRight(15);
Console.Write(s2);//padding at right side (15-8=7)
Console.Write("JavaTpoint");//will be written after 7 white spaces
}
}
Output: Hello C# JavaTpoint
Next TopicC# String Remove()
|