0

There are 16 colors in C#:

  • Black,
  • DarkBlue,
  • DarkGreen,
  • DarkCyan,
  • DarkRed,
  • DarkMagenta,
  • DarkYellow,
  • Gray,
  • DarkGray,
  • Blue,
  • Green,
  • Cyan,
  • Red,
  • Magenta,
  • Yellow, and
  • White

Is there any way I can add more colors (like brown, orange, etc.)?

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
tomer
  • 23
  • 6
  • The palette is limited to 16 values, they can be whatever you like but you cannot exceed that limit. – Alex K. Nov 21 '15 at 14:58

4 Answers4

2

Well, probably you can use a bitwise XOR ^ like below which will produce a different color altogether but probably you will have to know the color combination already.

  //Will produce a dark green color
Console.BackgroundColor = ConsoleColor.Yellow ^ ConsoleColor.Red;
Rahul
  • 76,197
  • 13
  • 71
  • 125
2

I'm afraid not, because Windows console (a.k.a. The Command Prompt) supports 16 colors only.

https://learn.microsoft.com/en-us/dotnet/api/system.console.backgroundcolor?redirectedfrom=MSDN&view=netframework-4.7.2#System_Console_BackgroundColor

Morgosus
  • 807
  • 5
  • 18
hemme
  • 1,654
  • 1
  • 15
  • 22
0

Command prompt supports 16 colors only

https://learn.microsoft.com/en-us/dotnet/api/system.console.backgroundcolor?redirectedfrom=MSDN&view=netframework-4.7.2#System_Console_BackgroundColor

Morgosus
  • 807
  • 5
  • 18
peter
  • 8,158
  • 21
  • 66
  • 119
0

You cannot add more colors, but you can redefine a color you aren't otherwise using: https://stackoverflow.com/a/7937272/57986

John Gietzen
  • 48,783
  • 32
  • 145
  • 190
  • A link to a solution is welcome, but please ensure your answer is useful without it: [add context around the link](//meta.stackexchange.com/a/8259) so your fellow users will have some idea what it is and why it’s there, then quote the most relevant part of the page you're linking to in case the target page is unavailable. [Answers that are little more than a link may be deleted.](//stackoverflow.com/help/deleted-answers) – Machavity Feb 24 '19 at 23:37