Console.ResetColor() Method in C#

The Console.ResetColor() method in C# is used to set the foreground and background console colors to their defaults.

Syntax

The syntax is as follows −

public static void ResetColor ();

Example

Let us now see an example to implement the Console.ResetColor() method in 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!");
   }
}

Output

This will produce the following output −

Updated on: 2019-11-14T05:58:19+05:30

417 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements