System.ConsoleColor

Enum

Specifies standard foreground and background colors for the console.

Members

Black
(Value: 0)
The color black.
Blue
(Value: 1)
The color blue.
Cyan
(Value: 3)
The color cyan.
Gray
(Value: 8)
The color gray.
Green
(Value: 2)
The color green.
Magenta
(Value: 5)
The color magenta.
Red
(Value: 4)
The color red.
White
(Value: 15)
The color white.
Yellow
(Value: 6)
The color yellow.
DarkBlue
(Value: 9)
The color dark blue.
DarkCyan
(Value: 11)
The color dark cyan.
DarkGray
(Value: 7)
The color dark gray.
DarkGreen
(Value: 10)
The color dark green.
DarkMagenta
(Value: 13)
The color dark magenta.
DarkRed
(Value: 12)
The color dark red.
DarkYellow
(Value: 14)
The color dark yellow.

Remarks

The ConsoleColor enumeration defines the set of standard colors that can be used to set the foreground and background colors of the console output. These values correspond to the standard ANSI colors and are used in conjunction with the Console.ForeColor and Console.BackgroundColor properties.

Example Usage

using System; public class Example { public static void Main() { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("This text is yellow."); Console.BackgroundColor = ConsoleColor.Blue; Console.WriteLine("This text has a blue background."); Console.ResetColor(); // Resets to default colors Console.WriteLine("This text is back to default."); } }