Last active
April 23, 2021 08:21
-
-
Save gsscoder/ea120292d0ca053e565bf9b94fb5f170 to your computer and use it in GitHub Desktop.
C# console helper (colors and bold)
This file contains 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
using System; | |
sealed class ConsoleEx | |
{ | |
public void Write(ConsoleColor color, string format, params object[] arg) | |
{ | |
var current = Console.ForegroundColor; | |
Console.ForegroundColor = color; | |
Console.Write(format, arg); | |
Console.ForegroundColor = current; | |
} | |
public void WriteLine(ConsoleColor color, string format, params object[] arg) => | |
Write(color, $"{format}\n", arg); | |
public void WriteBold(string format, params object[] arg) => | |
Console.Write($"\x1b[1m{format}\x1b[0m", arg); | |
public void WriteBoldLine(string format, params object[] arg) => | |
WriteBold($"{format}\n", arg); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment