C # Can Console Overflow Can Too Many Writelines?

If I have a program that executes Console.Writeline several times per second, and the program remains running for a long period of time, can the console overflow have too many lines? I just want to know if it will ultimately throw an IO exception or a Console.Writelines number is almost endless.

+6
source share
3 answers

No, it will not overflow. If you check the Options tab for a shortcut in the command window, you will see a buffer size option. This indicates the maximum number of rows to be saved. Old ones are deleted.

As Scott points out in his comment below, you can access this parameter from your code using Console.BufferHeight . The default value for this (when I tested on my development PC) is 300 . The maximum allowable value is 32766 ( Int16.MaxValue - 1 ).

+19
source

The console has a buffer with the number of lines that you can save, you can set it in the properties of cmd.exe:

Cmd.exe properties

So, after 300 lines, he will forget what was printed on line 1.

+4
source

the maximum allowable value is 32766 (fixed);

+1
source

Source: https://habr.com/ru/post/919852/


All Articles