String Padright() - C# Tutorial
C# Course / Strings / String Padright()

String Padright()

BLUF: Mastering String Padright() is essential for building robust applications with the .NET ecosystem. This tutorial provides clear explanations and practical examples to help you understand and apply this C# concept.
Enterprise Development Tip: String Padright()

C# is a powerful, modern language for enterprise solutions. Discover how String Padright() enhances your development workflow in the guide below.

The C# PadRight function is employed to generate a fresh string that aligns the characters to the left within the string by adding spaces to the right side, up to a designated 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:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience