RRKS101_1 TF2
RRKS101_1 TF2

Reputation: 158

C# | Changing the size of the consoles buffer below what was initially set

I'm wondering if its possible to change the size of the consoles buffer, as the included Console.SetBufferSize function will not allow you to shrink the buffer. bonus points if I don't need a external library.

Upvotes: 0

Views: 482

Answers (1)

Longoon12000
Longoon12000

Reputation: 784

According to the MSDN documentation of Console.SetBufferSize it is not limited to growing the buffer. However you have to adjust the console window size before shrinking the buffer.

This example works:

Console.WriteLine($"Current buffer size: {Console.BufferWidth}x{Console.BufferHeight}");
Console.SetWindowSize(1, 1);
Console.SetBufferSize(80, 80);
Console.SetWindowSize(40, 20);
Console.WriteLine($"New buffer size: {Console.BufferWidth}x{Console.BufferHeight}");

Output:

Current buffer size: 120x9001
New buffer size: 80x80

Upvotes: 1

Related Questions