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. | |
| Blue | The color blue. | |
| Cyan | The color cyan (blue-green). | |
| DarkBlue | The color dark blue. | |
| DarkCyan | The color dark cyan (dark blue-green). | |
| DarkGray | The color dark gray. | |
| DarkGreen | The color dark green. | |
| DarkMagenta | The color dark magenta (dark purplish-red). | |
| DarkRed | The color dark red. | |
| DarkYellow | The color dark yellow (ochre). | |
| Gray | The color gray. | |
| Green | The color green. | |
| Magenta | The color magenta (purplish-red). | |
| Red | The color red. | |
| White | The color white. | |
| Yellow | The color yellow. |
The following example saves the values of the ConsoleColor enumeration to an array and stores the current values of the BackgroundColor and ForegroundColor properties to variables. It then changes the foreground color to each color in the ConsoleColor enumeration except to the color that matches the current background, and it changes the background color to each color in the ConsoleColor enumeration except to the color that matches the current foreground. (If the foreground color is the same as the background color, the text isn't visible.) Finally, it calls the ResetColor method to restore the original console colors.
Available since 2.0