HomeSearch

C# Console.WindowHeight

This C# program uses the Console.WindowHeight property. It gets the LargestWindowHeight.
Console.WindowHeight changes the height of Console windows. This can make certain Console programs much easier to use, particularly if they have a lot of output. We test the Console.WindowHeight property.Console.WriteLineProperty
Minimum and maximum values for WindowHeight Minimum height = 1 Maximum height = 83
Example. You can change the height of the Console window by assigning to the WindowHeight property. The hard part is choosing a value. You can find the largest available height with the LargestWindowHeight property. The minimum height is 1.

Info: On the present system, it goes from the minimum height of 1 to the maximum height of 83 rows.

And: Depending on your screen resolution, you may have a different maximum number of rows.

C# program that tests Console.WindowHeight using System; using System.Threading; class Program { static void Main() { for (int i = 1; i <= Console.LargestWindowHeight; i++) { Console.Clear(); Console.WriteLine("Height = {0}", i); Console.WindowHeight = i; Thread.Sleep(100); } } } Output Height = 83 Press any key to continue...
Discussion. What are some ideas for finding the best window height? Unfortunately, if you set the WindowHeight to LargestWindowHeight, this will cause the window to go off the screen unless it is at the very top.

Therefore: It might be better to use a size that is a few rows smaller than LargestWindowHeight. Try subtracting 20 from it.

Summary. Console programs can be made more usable. One way you can do this is by adjusting the height of the window to make more text readable, as with the Console.WindowHeight and Console.LargestWindowHeight properties.
© 2007-2019 Sam Allen. Every person is special and unique. Send bug reports to info@dotnetperls.com.
Home
Dot Net Perls