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();
}

猜你喜欢

转载自www.cnblogs.com/anjun-xy/p/12896061.html