Computer >> Computer tutorials >  >> Programming >> C#

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 −

Console.ResetColor() Method in C#