ConsoleColor Enumeration
Specifies constants that define foreground and background colors for the console.
Assembly: mscorlib (in mscorlib.dll)
| Member name | Description | |
|---|---|---|
| Black | The color black. | |
| DarkBlue | The color dark blue. | |
| DarkGreen | The color dark green. | |
| DarkCyan | The color dark cyan (dark blue-green). | |
| DarkRed | The color dark red. | |
| DarkMagenta | The color dark magenta (dark purplish-red). | |
| DarkYellow | The color dark yellow (ochre). | |
| Gray | The color gray. | |
| DarkGray | The color dark gray. | |
| Blue | The color blue. | |
| Green | The color green. | |
| Cyan | The color cyan (blue-green). | |
| Red | The color red. | |
| Magenta | The color magenta (purplish-red). | |
| Yellow | The color yellow. | |
| White | The color white. |
The following code example demonstrates the System.ConsoleColor enumeration in conjunction with the Console.ForegroundColor and Console.BackgroundColor properties, and the Console.ResetColor method. You must run the example on a console to see the described color effects.
Two constants, Black and White, are used directly; then all the constants (Blue, DarkRed, and so on) are used indirectly in a loop. First, the names of the constants are obtained by using the GetNames method, which is inherited from the Enum class. Then the Enum.Parse method uses each name to create the corresponding enumerated constant.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.