Warm tip: This article is reproduced from serverfault.com, please click

Can't figure out how to get rid of blank space at the bottom of windows console in C#

发布于 2020-12-01 02:17:06

I'm using the console for a small console game I'm creating for fun but I've run into a problem.

The console for the game is always having this consistent amount of blank lines at the end of it that just take up space. I can literally make a completely fresh project with nothing in it, run it and it gives the same blank lines. I don't know how to fix this. See image for example.

Console Screen

Questioner
goose.mp4
Viewed
0
Jamshaid K. 2020-12-01 12:05:59

To get rid of the scrolls and the blank space that you see in the Console window, you need to make the console screen buffer same as the console window size. Use the code below:

Console.SetBufferSize(Console.WindowWidth, Console.WindowHeight);

Alternatively, if you want to do it manually, for specific console screens such as command prompt, you can get rid of the blank space by going into properties of the window like this: Console Window

And then navigate to the Terminal tab and check Disable Scroll-Forward checkbox from there.

Disable Scroll-Forward