How to pad the beginning of a string with specific character in C#

1 Answer

0 votes
using System;

class Program
{
    static void Main() {
        string s = "c# pro";
        
        char pad = '.';

        Console.WriteLine(s.PadLeft(17, pad)); 
    }
}
 
 
 
 
/*
run:
 
...........c# pro
 
*/

 



answered Nov 19, 2021 by avibootz

Related questions

1 answer 166 views
1 answer 162 views
1 answer 148 views
1 answer 184 views
1 answer 224 views
1 answer 219 views
1 answer 150 views
...