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.

Signature

Example

public string PadRight(Int32 length)
public string PadRight(Int32, Char)

Parameter

length: it is an integer type parameter.

Return

It returns a string.

C# String PadRight Method Example

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("Hello World");//will be written after 7 white spaces
       }  
    }

Output:

Output

Hello C#       C# Tutorial

Input Required

This code uses input(). Please provide values below: