Home > OS >  Why using tabs with Console.WriteLine don't show background color?
Why using tabs with Console.WriteLine don't show background color?

Time:11-13

When you print tabs using Console.WriteLine, they never use the specified background color:

Console.BackgroundColor = ConsoleColor.Red;
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("No tabs, no spaces");
Console.WriteLine("\tTabs don't have background color");
Console.WriteLine("    Spaces have background color");

enter image description here

Did I miss something or is it by design?

CodePudding user response:

After some testing it looks like this is related to how the native Visual Studio debugger renders the output and is not by fault of your code or app.

e.g. See below a side by side running a sample through the debugger vs directly through command line.

enter image description here

  • Related