หากต้องการเปลี่ยนสีพื้นหน้าของข้อความ ให้ใช้คุณสมบัติ Console.ForegroundColor ใน C#
ตัวอย่าง
using System;
class Demo {
public static void Main (string[] args) {
Console.BackgroundColor = ConsoleColor.Blue;
Console.WriteLine("Background color changed = " + Console.BackgroundColor);
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("\nForeground color changed = " + Console.ForegroundColor);
}
}ผลลัพธ์
