Alternative method of maximizing the console window - C #

I am creating a prototype for the part of the functionality that I will implement in the application, in particular, I show the data from the collection to the console window, but, unfortunately, some of the lines have a width that exceeds the default width of the console window.

alt text

I did a little digging and found that the only way to increase the width of the window is to dig into Kernel32.dll and do it manually.

As elegant as pInvoke, there is a β€œshorter” way to increase the width, for example. (Console.Width = 300) or uses Kernel32.dll the only way.

Thanks!

+4
source share
1 answer

No programming required. Create a shortcut for your desktop program. Right-click it, Properties tab, Layout. Adjust the Width property of the screen buffer and window size.

But you can do it also programmatically, these Windows API functions that you found are also completed by the Console class. For instance:

static void Main(string[] args) { Console.BufferWidth = 100; Console.SetWindowSize(Console.BufferWidth, 25); Console.ReadLine(); } 
+2
source

All Articles