Open E-School

Friday, February 24, 1984

Console.ResetColor() - How to reset console color using C#

Category: Programming Date: Monday, March 23, 2015

Goal – Learn how to reset the console background and foreground color to default color using C#

Namespaces used

System – Console class is defined in the System namespace

Classes used


Methods used

Console.ResetColor() – Static method defined in the Console class

Brief description

After you have made changes to the console background and foreground colors using the Console.BackgroundColor and Console.ForegroundColor properties in C# you can reset the colors back to the default Console colors using Console.ResetColor() method.


using System;    namespace ConsoleApplication1  {      class Program      {          public static void Main(string[] args)          {              Console.BackgroundColor = ConsoleColor.Red;              Console.ForegroundColor = ConsoleColor.Yellow;              Console.WriteLine("Hello World");                Console.ResetColor();              Console.WriteLine("Old color...");          }      }  }


Console.ResetColor() Output
Explanation of the code

In the code above we have first changed the background and foreground colors of the console by setting Console.BackgroundColor property to ConsoleColor.Red and the Console.ForegroundColor property to Console.Yellow. The we print the Hello world string using Console.WriteLine(“Hello world”) line. After this we are resetting the console colors to their default value by using the Console.ResetColor() method. And finally when we print the last line on the console window it gets printed in the default colors.

Rate this article and help us improve

Please Login to rate
Overall ratings: 0 | Rating: out of 5
Previous Article Next Article

Quick Links



Total Followers
Study Group Created
Study Group Joined
Following Teacher
Following Organization
Blog Articles Added
Questions Asked
Questions Answered
Jobs Posted
Total Members in Group
Questions asked by members
Tasks added in this Group

Please wait..


Login to Open ESchool OR Create your account    Login   SignUp