System.Console.Clear Method

Clears the console buffer and corresponding console window of display information.

Syntax

public static void Clear ()

Remarks

Using the Console.Clear method is equivalent invoking the MS-DOS cls command in the command prompt window. When the Console.Clear method is called, the cursor automatically scrolls to the top-left corner of the window and the contents of the screen buffer are set to blanks using the current foreground background colors.

Note:

Attempting to call the Console.Clear method when a console application's output is redirected to a file throws a System.IO.IOException. To prevent this, always wrap a call to the Console.Clear method in a try…catch block.

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0