Home
Search
C# Console.WindowHeightUse the Console.WindowHeight property and get 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
Property
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.
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.
Minimum and maximum values for WindowHeight:
Minimum height = 1 Maximum height = 83
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.
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); } } }
Height = 83 Press any key to continue...
Home
© 2007-2022 sam allen.
see site info on the changelog.