I am trying to print 1820 lines in C# console window. However, when the printing is done and I view the console window, I can see only 300 lines. What is the problem here? When I write to file, I can see 1820 lines! So, I have narrowed down the problem to the OUTPUT console window
The standard console window in most versions of Windows have a limited buffer of lines they keep - 300 lines sounds like a reasonable buffer.
You can see (and change) that limit when you open a cmd.exe
window and then right-click on the icon in the top left corner and choose Properties
from the context menu:
You might be able to increase the size of that buffer to give you more lines - keep in mind that those lines will take up RAM from your system while your console window is open!
You can use Console.SetBufferSize() to make the console buffer larger:
class Program {
static void Main(string[] args) {
Console.SetBufferSize(Console.WindowWidth, 2000);
// etc..
}
}
--Small Addition--
If hoping to get the maximum possible buffer:
Console.SetBufferSize(Console.WindowWidth, Int16.MaxValue-1);
You're not allowed anything >= Int16.MaxValue
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With