- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to clear screen using C#?
Use the Console.Clear() method to clear screen and the console buffer. When the Clear method is called, the cursor automatically scrolls to the top-left corner of the window.
Here, we have cleared the screen and then set the ForegroundColor and BackgroundColor −
ConsoleColor newForeColor = ConsoleColor.Blue; ConsoleColor newBackColor = ConsoleColor.Yellow;
The following is the complete code −
Example
using System; using System.Collections.Generic; class Program { static void Main() { ConsoleColor foreColor = Console.ForegroundColor; ConsoleColor backColor = Console.BackgroundColor; Console.WriteLine("Clearing the screen!"); Console.Clear(); ConsoleColor newForeColor = ConsoleColor.Blue; ConsoleColor newBackColor = ConsoleColor.Yellow; } }
Output
Clearing the screen!
- Related Articles
- How to clear screen using python?
- How to clear screen using Java?
- How to clear screen in python?
- How can I clear console using C++?
- How to clear console in C?
- How to print to the Screen using Python?
- How to create a Splash Screen using Tkinter?
- How to create a simple screen using Tkinter?
- How to reset or clear a form using JavaScript?
- How to clear an ImageView in Android using Kotlin?
- How to open a browser window in full screen using Selenium WebDriver with C#?
- How to center a popup window on screen using JavaScript?
- How to center a div on the screen using jQuery?
- How to clear Tkinter Canvas?
- How to clear Python shell?

Advertisements