Skip to content

Instantly share code, notes, and snippets.

@NrI3
Created June 10, 2016 22:10
Show Gist options
  • Select an option

  • Save NrI3/c2d771161fb0849170b5592f5cf93795 to your computer and use it in GitHub Desktop.

Select an option

Save NrI3/c2d771161fb0849170b5592f5cf93795 to your computer and use it in GitHub Desktop.
Colorea tu consola :p
public static class Consola
{
public static void WriteLine(string msg, params string[] arg)
{
string temp = "";
bool x = false;
int p = 0;
foreach (char c in msg)
{
if (c == '}' && x)
{
x = false;
Console.Write(temp);
if (p < arg.Length) Console.Write(arg[p]);
temp = "";
Console.ResetColor();
p++;
continue;
}
else if (c == '{' && !x)
{
x = true;
if (temp != "") { Console.Write(temp); temp = ""; }
continue;
}
else if (x)
{
if (c == 'y') Console.ForegroundColor = ConsoleColor.Yellow;
else if (c == 'r') Console.ForegroundColor = ConsoleColor.Red;
else if (c == '0') Console.ResetColor();
continue;
}
else
{
temp += c;
}
}
if (arg.Length == 0) Console.Write(temp);
Console.WriteLine();
Console.ResetColor();
}
public static string ReadLine(char c)
{
if (c == 'y') Console.ForegroundColor = ConsoleColor.Yellow;
else if (c == 'r') Console.ForegroundColor = ConsoleColor.Red;
return Console.ReadLine();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment