How do I write color text to the Visual Studio output window from c#?

前端 未结 7 1972
忘了有多久
忘了有多久 2020-12-19 06:16

I want to write color text to the Visual Studio output window from c#. I want to output red code from my unit tests.

7条回答
  •  独厮守ぢ
    2020-12-19 07:02

    Edited The code below works to display output in Windows Console, not to Visual Studio Output window (thanks @AnthonyLambert for correcting me).

     Console.ForegroundColor = ConsoleColor.Magenta; //Choose from the Enum
     Console.WriteLine("This message is to be in Magenta!");
     Console.ResetColor();//Reset to default
    

提交回复
热议问题