I am having a problem. I am making a TUI program. Everything is fine except the fact that I don't like the UI. So I am trying to center my texts to make it seem better. But I am not able to no matter what!
I tried something like this:
string s = "Hello World!";
Console.SetCursorPosition((Console.WindowWidth - s.Length) / 2, Console.CursorTop);
Console.WriteLine(s);
BUT this does not work when I have multiple lines. For example,
string s = "Hello World!\nHey this is another line!";
Console.SetCursorPosition((Console.WindowWidth - s.Length) / 2, Console.CursorTop);
Console.WriteLine(s);
See if these work for you, one starts at top of screen while the other centers horizontally and vertically.