Created
June 10, 2016 22:10
-
-
Save NrI3/c2d771161fb0849170b5592f5cf93795 to your computer and use it in GitHub Desktop.
Colorea tu consola :p
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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