Console.SetBufferSize() Method in C#


The Console.SetBufferSize() Method in C# is used to set the height and width of the screen buffer area to the specified values.

Syntax

The syntax is as follows −

public static void SetBufferSize (int width, int height);

Above, the parameter width is the width of the buffer area, whereas height is the height of the buffer area.

Example

Let us now see an example to implement the Console.SetBufferSize() Method in C# −

using System;
class Demo {
   public static void Main (string[] args) {
      Console.BackgroundColor = ConsoleColor.White;
      Console.ForegroundColor = ConsoleColor.Red;
      Console.SetBufferSize(400, 400);
      while (true) {
         Console.WriteLine("Our demo text!");
      }
   }
}

Output

This will produce the following output −

Updated on: 14-Nov-2019

151 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements