Given the normal Console in C#, the default color of the text foreground is “Black”. The task is to change this color to some other color.
Approach: This can be done using the ForegroundColor property in the Console class of the System package in C#.
Program 1: Changing the Console Foreground Color to Blue.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GFG {
class Program {
static void Main( string [] args)
{
Console.WriteLine( "Default Foreground Color: {0}" ,
Console.ForegroundColor);
Console.ForegroundColor
= ConsoleColor.Blue;
Console.WriteLine( "Changed Foreground Color: {0}" ,
Console.ForegroundColor);
}
}
}
|
Output:

Program 2: The list of available colors in which the ForegroundColor can be changed are
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GFG {
class Program {
static void Main( string [] args)
{
ConsoleColor[] consoleColors
= (ConsoleColor[])ConsoleColor
.GetValues( typeof (ConsoleColor));
Console.WriteLine( "List of available "
+ "Console Colors:" );
foreach ( var color in consoleColors)
Console.WriteLine(color);
}
}
}
|
Output:

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!