Heisenberg
Heisenberg
Explore posts from servers
CC#
Created by Heisenberg on 5/13/2023 in #help
❔ 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);
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
#################### Hello, World
The output i wanted
#################### Hello, World ####################
#################### Hello, World ####################
72 replies