I'm trying to use Console.SetWindowSize() to change the window size of the Console, for a C# Console application. In previous versions of Visual Studio or Windows, this would work. Now it does not.
Steps to reproduce:
In Windows 11, Visual Studio 2019, create a new C# Console App (.NET Framework) application
Add the code to the main function:
Console.SetWindowSize(10, 10);
Console.WriteLine("Hello world");
Console.ReadLine();
I've seen this answer which suggests changing the terminal output mode. I tried setting the terminal output using Enviroment > Terminal from the settings search bar in Visual Studio 2019, to either Developer Command Prompt or Ubuntu WSL terminals, but neither allowed resizing the Console window.
Is there a solution?
Please adjust the following settings
The following is the console output
static void Main(string[] args)
{
Console.WindowHeight = 20;
Console.WindowWidth = 20;
Console.WriteLine("Test 1");
Console.WriteLine("Max height: " + Console.LargestWindowHeight.ToString());
Console.WriteLine("Max width: " + Console.LargestWindowWidth.ToString());
Console.ReadKey();
Console.Clear();
Console.SetWindowSize(10, 10);
Console.WriteLine("Test 2");
Console.WriteLine("Max height: " + Console.LargestWindowHeight.ToString());
Console.WriteLine("Max width: " + Console.LargestWindowWidth.ToString());
Console.ReadKey();
Console.Clear();
}