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...
After that, we will reset the colors to default.");       Console.BackgroundColor = ConsoleColor.White;       Console.ForegroundColor = ConsoleColor.Red;       Console.WriteLine ("
Colors are set for this text");       Console.ResetColor();       Console.WriteLine ("
Now we reset the color to default!");    } }

Output

This will produce the following output −

Updated on: 14-Nov-2019

176 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements