Open E-School

Friday, February 24, 1984

Console.ForegroundColor – How to change text color in Console window using C#

Category: Programming Date: Monday, March 23, 2015

Goal – Learn how to change the text color in a console window using C#

Namespaces used

System – Console class is defined in the System namespace

Classes used


Properties used

Console.ForegroundColor – Static property defined in the Console class

Brief description

When working on console applications in C# you see that the default background color of the console is black and the default text color is white. Our goal is to learn how to change the default white color of the text to a different color which we want.


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


Console.ForegroundColor - Output
Explanation of the code

In the above code we are setting the Console.ForegroundColor property to yellow. When you run the application you see that the text color has now changed to yellow in place of the default white text which you saw earlier.

Extra Remarks

Console.ForegroundColor is an enum type property. You will have to select the color which you want to set from the ConsoleColor enum.

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