Phương thức Console.ResetColor () trong C # được sử dụng để đặt màu nền trước và nền của bảng điều khiển thành màu mặc định của chúng.
Cú pháp
Cú pháp như sau -
public static void ResetColor ();
Ví dụ
Bây giờ chúng ta hãy xem một ví dụ để triển khai phương thức Console.ResetColor () trong 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!");
}
} Đầu ra
Điều này sẽ tạo ra kết quả sau -