Instantly share code, notes, and snippets.

What would you like to do?
C# extension/helper class for writing colored output to the console. This is sort-of a workaround of not being able to extend the static Console class.
using System;
namespace Utilities.Extensions
public static class ConsoleColorExtensions
/// <summary>
/// Writes the specified string value, followed by the current line terminator, to the standard output stream.
/// </summary>
/// <example>
/// ConsoleColor.Green.WriteLine("The task executed successfully");
/// </example>
/// <param name="foregroundColor">Foreground color.</param>
/// <param name="value">The value to write.</param>
public static void WriteLine(this ConsoleColor foregroundColor, string value)
var originalForegroundColor = Console.ForegroundColor;
Console.ForegroundColor = foregroundColor;
Console.ForegroundColor = originalForegroundColor;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment