Learn to Code via Tutorials on Repl.it!

← Back to all posts
Color Your Text w/ C#
viraatvv (147)

You probably know how to color text with Python, right?

Probably Yes

Well, I found out how to Color Your Text With C#!(coz that is the name of this tutorial)
It is really easy, but there is one problem - it doesn't have ALL the colors in the universe, and you have to spell grey like "gray".
To know ALL the available colors, do the following algorithm below:

ConsoleColor[] consoleColors =(ConsoleColor[])ConsoleColor.GetValues(typeof(ConsoleColor)); 
Console.WriteLine("List of available "+ "Console Colors:"); 
foreach(var color in consoleColors) 

Now, to color the text!

To color your text red, input the following code below:

Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Hello, World");

You probably know how to change the color :).
To change it back, then do this:

Console.ForegroundColor = ConsoleColor.White;

And then Console.WriteLine(); !

Well, That is the end for now, so see ya all later!