C# Console ResetColor() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Console

Definition

In C#, Console.ResetColor sets the console’s foreground and background colors back to the system defaults for the session.

You typically change Console.ForegroundColor or BackgroundColor for emphasis, then call ResetColor so later text is not stuck in the highlight color.

This is a static member of System.Console. You call it with the type name, such as Console.ResetColor(...). Console is the everyday API for reading from standard input and writing to standard output in C# console apps.

Syntax

Set colors, write, then call ResetColor().

C#
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("Warning");
Console.ResetColor();
CallWhat it does
Console.ResetColor()Restores default foreground and background colors.

Color support depends on the terminal. ResetColor returns you to the defaults the runtime tracks.

Library declarations
C#
public static void ResetColor();

Parameters

ParameterDescription
NoneResetColor() takes no parameters.

Return Value

Return ValueDescription
voidColors are restored; nothing is returned.

C# Examples

Example 1 — Yellow Warning Then Reset

Highlight a warning, then return to default colors.

C#
using System;

class Program {
    static void Main() {
        Console.ForegroundColor = ConsoleColor.Yellow;
        Console.WriteLine("Warning: disk almost full");
        Console.ResetColor();
        Console.WriteLine("Back to normal text");
    }
}

How It Works

  1. Set yellow. ForegroundColor changes upcoming text color.
  2. Warning line. Printed while yellow is active.
  3. ResetColor. Defaults return for the next line.
  4. Normal text. Final line uses the restored colors.

Example 2 — Red Error Message

Use red for errors, then reset.

C#
using System;

class Program {
    static void Main() {
        Console.ForegroundColor = ConsoleColor.Red;
        Console.WriteLine("Error: file not found");
        Console.ResetColor();
        Console.WriteLine("Please try again");
    }
}

How It Works

  1. Red foreground. Signals an error visually.
  2. Reset after. Prevents the whole session staying red.
  3. Follow-up help. Guidance prints in default color.
  4. sample output. Shows text; your terminal shows the colors.

Example 3 — Color a Header Only

Color a title, reset, then print a body.

C#
using System;

class Program {
    static void Main() {
        Console.ForegroundColor = ConsoleColor.Cyan;
        Console.WriteLine("=== Report ===");
        Console.ResetColor();
        Console.WriteLine("Items: 3");
        Console.WriteLine("Status: OK");
    }
}

How It Works

  1. Cyan header. Only the title uses the accent color.
  2. Immediate reset. Body lines stay default.
  3. Readable structure. Color marks the section without flooding it.
  4. Two body lines. Printed after ResetColor.

Frequently Asked Questions

The default foreground and background colors for the console session.
Call it after temporary color changes so later text is not stuck colored.
Console.ForegroundColor and Console.BackgroundColor.
Support depends on the terminal or host.
No. ResetColor fixes colors; Clear erases the screen.

Next: SetBufferSize()

Change the width and height of the console screen buffer with System.Console.

SetBufferSize() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

7 people found this page helpful