In this post, we’re going to see how we can spice up our console projects and upgrade the user experience using one of open-source c# library.
Colorful.Console is a C# library that wraps around the System.Console class, exposing enhanced styling functionality
ADDING PACKAGE
Here we are adding Nuget package "Colorful.console"
CODE
using Colorful;
using System;
using System.Drawing;
using Console = Colorful.Console;
namespace ColorConsole
{
class Program
{
static void Main(string[] args)
{
//print lines in color
Console.WriteLine("console in Orange", Color.Orange);
Console.WriteLine("console in RGB color", Color.FromArgb(123, 214, 56));
//Text formating
string words = "ABC {0} PQR {1}";
string[] colorWords = new string[]
{
"MANOJ",
"DHOBALE"
};
Console.WriteLineFormatted(words, Color.Brown, Color.Yellow, colorWords);
//Convert text to ASCII art
int DA = 244;
int V = 22;
int ID = 233;
Console.WriteAscii("SHLOK", Color.FromArgb(DA, V, ID));
Console.ReadKey();
}
}
}
using Colorful; using System; using System.Drawing; using Console = Colorful.Console; namespace ColorConsole { class Program { static void Main(string[] args) { //print lines in color Console.WriteLine("console in Orange", Color.Orange); Console.WriteLine("console in RGB color", Color.FromArgb(123, 214, 56)); //Text formating string words = "ABC {0} PQR {1}"; string[] colorWords = new string[] { "MANOJ", "DHOBALE" }; Console.WriteLineFormatted(words, Color.Brown, Color.Yellow, colorWords); //Convert text to ASCII art int DA = 244; int V = 22; int ID = 233; Console.WriteAscii("SHLOK", Color.FromArgb(DA, V, ID)); Console.ReadKey(); } } }