How to Change Color of Text in C# Program

This is the simple C# program to change the color of text in console. The beginner programmers can make their output of the program funny and interesting with this code.

Source Code 

using System;
using System.Collections.Generic;
using System.Text;
namespace assad
{
class sortArrays
{

static void Main(string[] args)
{
welcomeScrean();
if (Console.BackgroundColor == ConsoleColor.Black)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Color is Red");
Console.ForegroundColor = ConsoleColor.Magenta;
Console.WriteLine("Color is Magenta");
Console.ForegroundColor = ConsoleColor.Gray;
Console.WriteLine("Color is Gray");
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine("Color is DarkYellow");
Console.ForegroundColor = ConsoleColor.DarkCyan;
Console.WriteLine("Color is DarkCyan");
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("Color is Blue");
}
Console.ReadKey();
}
private static void welcomeScrean()
{
Console.ForegroundColor = ConsoleColor.Green;
Console.Write("\t*******************************************************" + "\n"
+ "\t*******************************************************" + "\n"
+ "\t** Change Console Color **" + "\n"
+ "\t** Program **" + "\n"
+ "\t*******************************************************" + "\n"
+ "\t*******************************************************\n\n\n\n");
}

}
}

Output of the Program

Change Color of Text in C# Program

Share on Google Plus

About Asad

Asad Niazi is Software Engineer , Programmer, Web Developer and a young mentor of BloggersTown and PProgramming. Asad Love to writes about Technology, Programming, Blogging and make money online.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment