How do I write color text to the Visual Studio output window from c#?
In addition to Jeff Roe I've managed to get this:
Warnings: Console.WriteLine($"Warning: Warning '{message}'");
Errors: Console.WriteLine($"Error: Error '{message}'");
Sadly I could not figure out how to get green output. If any1 could add this I would be super happy !
I found this question while trying to figure out why some of the lines of text in my Visual Studio 2017 Output window are colored red, and how I could accomplish the same thing.
I found that I was able to get red text by writing out a line which included:
- an instance of "
Error:
" (Error, colon, followed by a space) - (other characters can go here)
- another instance of "
Error:
" (Error, colon, followed by a space) - (other characters can go here)
- followed by 1 instance of "
Error *
" (Error, followed by a space and then some other character) - (other characters can go here)
An example:
Debug.WriteLine("Error: This line will be red Error: Error Jeff");