So I am trying to color individual charactrs E.G "0 is allways red 1 is allways blue 2 is allways green etc." I am using a nuget package called "MathNet.Numerics.FSharp." And from that i am using BigRational (a BigRational is a infanate bit int.) in a Console.WriteLine E.G "Console.WriteLine(i);" and I am makeing a program with extreamly large numbers and I want to color the numbers to so I can look at the numbers and look for patterns. So can anyone plese help me whis this. Thank you in advance.
Ps If i did something rong plese don't get mad at me I am onlly 11 thank you for the acseptance.
CodePudding user response:
The CharacterColoring
function that I created can be used both singly and in a loop
.
It is used in the loop as follows:
Output:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp
{
class Program
{
public static void CharacterColoring(char YourChar, ConsoleColor YourFavoriteColor)
{
Console.ForegroundColor = YourFavoriteColor;
Console.Write(YourChar);
}
static void Main(string[] args)
{
string YourText = "Hello world 1 2";
for (int i = 0; i < YourText.Length; i )
{
if (YourText[i] == '1')
{
CharacterColoring(YourText[i], ConsoleColor.Red);
}
else if (YourText[i] == '2')
{
CharacterColoring(YourText[i], ConsoleColor.Blue);
}
else
{
CharacterColoring(YourText[i], ConsoleColor.Green);
}
}
Console.ReadKey();
}
}
}
Tested in:
Visual Studio 2017
, .NET Framework 4.5.2
, Console App
Best regards,
Reza Jaferi