I want to write color text to the Visual Studio output window from c#. I want to output red code from my unit tests.
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:
Error:
" (Error, colon, followed by a space)Error:
" (Error, colon, followed by a space)Error *
" (Error, followed by a space and then some other character)An example:
Debug.WriteLine("Error: This line will be red Error: Error Jeff");
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 !
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With