C#C
C#3y ago
Heisenberg

❔ Padding string from two sides

im trying to do padding of string from both side but it doesnt work.
The Code:
 string Hello = " Hello, World ";
        int padding = (Console.WindowWidth - Hello.Length) / 2;
        string Hello_Mod = Hello.PadLeft(padding,'#');
        string Hello_Modd = Hello_Mod.PadRight(padding,'#');
        Console.WriteLine(Hello_Modd);
        Console.WriteLine(padding);
        Console.WriteLine(Console.WindowWidth);
        Console.WriteLine(Hello.Length);
        Console.WriteLine(Console.WindowWidth / 2);

The ouput im getting:
#################### Hello, World


The output i wanted
#################### Hello, World ####################
Was this page helpful?