0

Currently, I'm working on a project in C# in which I'd like to be able to use my own custom colors rather than only the ConsoleColor colors. Preferably, I'd be able to input an RGB value, give the color a name, and be able to do something like this:

    Console.BackgroundColor = RGBColor(255, 174, 0);

I do realize that this question has already been asked a few times, but the solutions haven't been quite right for me. I've looked here, here, and here, but as I'm pretty new to C#, the answers just don't make sense, especially because I don't quite get what p/invoke is or does. Is there anything simple that I can do to implement RGB (from what I've read, I know the console supports it), or can anyone provide an explanation on the methods I've researched? Thanks in advance.

Community
  • 1
  • 1
jmindel
  • 465
  • 1
  • 7
  • 16
  • The answers you found are pretty much the only option you have (short of limiting your application to usage within [ConEmu](https://code.google.com/p/conemu-maximus5/)). You can [redefine the colour palette](http://stackoverflow.com/q/7937256/73070) but you are still limited to 16 distinct colours at a time. There is no better answer. Regarding ConEmu, you can look at the sources of it and Far Manager/Colorer to figure out how true colour can be used there. – Joey Jul 16 '14 at 07:41
  • 1
    p/invoke is for calling unmanaged dll. Mostly it is used for win API. And know that mostly net framework calls win api under hood. So dont worry just pass that code and use – qwr Jul 16 '14 at 07:43
  • 1
    Use [Colorful.Console](https://github.com/tomakita/Colorful.Console) which lets you set custom colours. – Muhammad Rehan Saeed Aug 24 '16 at 09:18

0 Answers0