Console.MoveBufferArea() Method in C#


The Console.MoveBufferArea() method in C# is used to copy a specified source area of the screen buffer to a specified destination area.

Syntax

The syntax is as follows −

public static void MoveBufferArea (int sourceLeft, int sourceTop, int sourceWidth, int sourceHeight, int targetLeft, int targetTop);

Here,

  • sourceLeft

             The leftmost column of the source area.

  • sourceTop

             The topmost row of the source area.

  • sourceWidth

             The number of columns in the source area.

  • sourceHeight

            The number of rows in the source area.

  • targetLeft

            The leftmost column of the destination area.

  • targetTop

            The topmost row of the destination area.

Example

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

using System;
class Demo {
   public static void Main (string[] args) {
      Console.WriteLine("Demo text!");
      Console.MoveBufferArea(0, 0, Console.BufferWidth, Console.BufferHeight, 20, 20);
   }
}

Output

This will produce the following output −

Updated on: 14-Nov-2019

146 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements