vscode integrate terminal Color issues with C#

I am trying to set background color of the console with Console.BackgroundColor property.

ColoredItem<Sword> blueSword = new ColoredItem<Sword>(new Sword(), ConsoleColor.Blue);
ColoredItem<Bow> redBow = new ColoredItem<Bow>(new Bow(), ConsoleColor.Red);
ColoredItem<Axe> yellowAxe = new ColoredItem<Axe>(new Axe(), ConsoleColor.Green);

blueSword.Display();
redBow.Display();
yellowAxe.Display();

Console.ReadLine();

public class ColoredItem<T>
{
    private T item;
    private ConsoleColor color;

    public ColoredItem(T item, ConsoleColor color)
    {
        this.item = item;
        this.color = color;
    }

    public void Display()
    {
        ConsoleColor prevBGColor = Console.BackgroundColor;
        Console.BackgroundColor = color;
        Console.WriteLine(item);
        Console.BackgroundColor = prevBGColor;
    }
}
public class Sword { } 
public class Bow { } 
public class Axe { } 


for some reason in vscode integrated terminal I get wrong colors but when running it via dedicated powershell or cmd terminal I don't. I searched around but I could only find a 7 year old issue that was marked resolved
image.png
image.png
Was this page helpful?