Computer >> คอมพิวเตอร์ >  >> การเขียนโปรแกรม >> C#

Console.ResetColor() วิธีการใน C #


เมธอด Console.ResetColor() ใน C# ใช้เพื่อตั้งค่าสีคอนโซลพื้นหน้าและพื้นหลังให้เป็นค่าเริ่มต้น

ไวยากรณ์

ไวยากรณ์มีดังนี้ −

public static void ResetColor ();

ตัวอย่าง

ให้เราดูตัวอย่างการใช้เมธอด Console.ResetColor() ใน C# −

using System;
class Demo {
   public static void Main (string[] args) {
      Console.WriteLine ("At first, we have set colors here...\nAfter that, we will reset the colors to default.");
      Console.BackgroundColor = ConsoleColor.White;
      Console.ForegroundColor = ConsoleColor.Red;
      Console.WriteLine ("\nColors are set for this text");
      Console.ResetColor();
      Console.WriteLine ("\nNow we reset the color to default!");
   }
}

ผลลัพธ์

สิ่งนี้จะสร้างผลลัพธ์ต่อไปนี้ -

Console.ResetColor() วิธีการใน C #