如何在 C# 控制檯中更改文字的背景顏色


要在控制檯中更改文字的背景顏色,請在 C# 中使用 Console.BackgroundColor 屬性。

示例

現在,讓我們看一個示例 −

using System;
class Demo {
   public static void Main (string[] args) {
      Console.BackgroundColor = ConsoleColor.Blue;
      Console.WriteLine("Background color changed = "+Console.BackgroundColor);
   }
}

輸出

將生成以下輸出 −

更新於: 14-11-2019

2 千次訪問量

開啟您的 事業

完成課程即可獲得認證

開始
廣告
© . All rights reserved.