Write Line with console color - CSharp System.Drawing

CSharp examples for System.Drawing:Color

Description

Write Line with console color

Demo Code


using System;//from   ww  w.  j  a v  a  2 s .  c  o  m

public class Main{
        public static void WriteLine(ConsoleColor color, object obj)
        {
            WriteLine(color, obj.ToString(), null);
        }
        public static void WriteLine(ConsoleColor color, string format, params object[] objects)
        {
            var previousColor = Console.ForegroundColor;
            Console.ForegroundColor = color;
            if (objects == null)
            {
                Console.WriteLine(format);
            }
            else
            {
                Console.WriteLine(format, objects);
            }
            Console.ForegroundColor = previousColor;
        }
}

Related Tutorials