System.ConsolePal.ResetColor C# (CSharp) Method

ResetColor() public static method

public static ResetColor ( ) : void
return void
        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);
        }

Usage Example

示例#1
0
文件: Console.cs 项目: TelsaV/corefx
 public static void ResetColor()
 {
     ConsolePal.ResetColor();
 }