Ad
Strings
Code
Diff
  • public class ColorAdder
    {
        public static string AddColor(string color, string text)
        {
          string Reset = "\033[0m";
          
          return color switch{
              "Red" => $"\033[31m{text}{Reset}",
              "Green" => $"\033[32m{text}{Reset}",
              "Yellow" => $"\033[33m{text}{Reset}",
              "Blue" => $"\033[34m{text}{Reset}",
              "Magenta" => $"\033[35m{text}{Reset}",
              "Cyan" => $"\033[36m{text}{Reset}",
              "White" => $"\033[37m{text}{Reset}",
              _ => ""
          };
        }
    }
    
    • public class ColorAdder
    • {
    • public static string AddColor(string color, string text)
    • {
    • string Reset = "\033[0m";
    • string Red = "\033[31m";
    • string Green = "\033[32m";
    • string Yellow = "\033[33m";
    • string Blue = "\033[34m";
    • string Magenta = "\033[35m";
    • string Cyan = "\033[36m";
    • string White = "\033[37m";
    • switch(color) {
    • case "Red":
    • return string.Concat(string.Concat(Red, text), Reset);
    • break;
    • case "Green":
    • return string.Concat(string.Concat(Green, text), Reset);
    • break;
    • case "Yellow":
    • return string.Concat(string.Concat(Yellow, text), Reset);
    • break;
    • case "Blue":
    • return string.Concat(string.Concat(Blue, text), Reset);
    • break;
    • case "Magenta":
    • return string.Concat(string.Concat(Magenta, text), Reset);
    • break;
    • case "Cyan":
    • return string.Concat(string.Concat(Cyan, text), Reset);
    • break;
    • case "White":
    • return string.Concat(string.Concat(White, text), Reset);
    • break;
    • default:
    • return "Invalid Color";
    • break;
    • }
    • return color switch{
    • "Red" => $"\033[31m{text}{Reset}",
    • "Green" => $"\033[32m{text}{Reset}",
    • "Yellow" => $"\033[33m{text}{Reset}",
    • "Blue" => $"\033[34m{text}{Reset}",
    • "Magenta" => $"\033[35m{text}{Reset}",
    • "Cyan" => $"\033[36m{text}{Reset}",
    • "White" => $"\033[37m{text}{Reset}",
    • _ => ""
    • };
    • }
    • }