In C#, Console.Clear erases the visible console content (the screen buffer area you see) and places the cursor at the upper-left corner.
Programs use it before redrawing a menu or starting a fresh “screen.” If output is redirected or the host has no interactive console, Clear may throw—keep that in mind for non-terminal environments.
This is a static member of System.Console. You call it with the type name, such as Console.Clear(...). Console is the everyday API for reading from standard input and writing to standard output in C# console apps.
Syntax
Call Console.Clear() with no arguments.
C#
Console.Clear();
Call
What it does
Console.Clear()
Clears the screen and homes the cursor.
Clear is console-window oriented. Redirected stdout may not support it.
Library declarations
C#
public static void Clear();
Parameters
Parameter
Description
None
Clear() takes no parameters.
Return Value
Return Value
Description
void
Nothing is returned; the display is updated.
C# Examples
Example 1 — Clear Then Print a Title
Wipe the console, then show a clean header.
C#
using System;
class Program {
static void Main() {
Console.WriteLine("Old text you will not see after Clear");
Console.Clear();
Console.WriteLine("Fresh start");
Console.WriteLine("Menu ready");
}
}
Output
Fresh start
Menu ready
How It Works
Old text gone. Clear removes what was on the screen.
Home cursor. New writes begin at the top-left.
Visible output. Only lines after Clear appear in sample output.
UI reset. Handy before drawing a menu again.
Example 2 — Clear Between Menu Screens
Simulate two screens by clearing between messages.
C#
using System;
class Program {
static void Main() {
Console.WriteLine("=== Screen A ===");
Console.WriteLine("Press Enter...");
Console.ReadLine();
Console.Clear();
Console.WriteLine("=== Screen B ===");
Console.WriteLine("Done");
}
}
Output
=== Screen A ===
Press Enter...
=== Screen B ===
Done
How It Works
First screen. Title A shows until the user presses Enter.
Sample Enter. Blank line in the narrative marks the empty ReadLine.
Clear bridge. Screen A is wiped before Screen B prints.
Second screen. Only the B messages remain visible afterward.
Example 3 — Refresh a Status Line
Clear and reprint so a status looks updated.
C#
using System;
class Program {
static void Main() {
for (int i = 1; i <= 3; i++) {
Console.Clear();
Console.WriteLine("Progress: step " + i + " of 3");
}
Console.WriteLine("Complete");
}
}
Output
Progress: step 3 of 3
Complete
How It Works
Loop refresh. Each iteration clears before printing the new step.
Last frame. sample output shows the final step text that remains.
Complete line. Printed after the loop without another clear.
Simple animation. Real apps may sleep between frames; this demo focuses on Clear.
Frequently Asked Questions
It clears the console screen buffer area and moves the cursor to (0, 0).
No. It only affects the console display, not disks or variables.
When there is no interactive console or the output is redirected in a way the host does not support.
No. Clear resets the buffer; newlines only scroll text.
Before redrawing menus or starting a clean visual section in a console UI.