C#控制台为输出内容设置背景色和字体颜色

static void Main(string[] args)
{
  Console.BackgroundColor = ConsoleColor.White;//设置背景色
  Console.ForegroundColor = ConsoleColor.Black;//设置字体颜色
  Console.WriteLine("  123");

  Console.BackgroundColor = ConsoleColor.Blue;
  Console.ForegroundColor = ConsoleColor.White;
  Console.WriteLine("  2222");

  Console.BackgroundColor = ConsoleColor.Gray;
  Console.ForegroundColor = ConsoleColor.Red;
  Console.WriteLine("  3333");
   

  Console.Read();
}

相关文章:

  • 2022-01-07
  • 2022-12-23
  • 2022-12-23
  • 2021-05-14
  • 2021-10-24
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-10
  • 2021-08-23
  • 2021-12-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案