public static void ResetColor()
{
if (!_haveReadDefaultColors) // avoid the costs of GetBufferInfo if we already know we checked it
{
bool succeeded;
GetBufferInfo(false, out succeeded);
if (!succeeded)
return; // For code that may be used from Windows app w/ no console
Debug.Assert(_haveReadDefaultColors, "Resetting color before we've read the default foreground color!");
}
// Ignore errors here - there are some scenarios for running code that wants
// to print in colors to the console in a Windows application.
Interop.Kernel32.SetConsoleTextAttribute(OutputHandle, (short)(ushort)_defaultColors);
}