please support Console.ForegroundColor
I use LinqPad for deployment scripts, and it would be really useful to be able to write error messages to the console in Red. Currently ForegroundColor does not work.
-
Gábor Győre commented
You can achieve this with the below function:
```
Util.WithStyle("ERROR MESSAGE", "font-weight: bold; color: #ee3333").Dump();
``` -
Daniel Rubin commented
I know this is a really old suggestion, but it's still the top google result for "linqpad output color". As such, there's a better way to do what Itsey suggests: The Util.WithStyle() function.
It can be used for console output (without losing whitespace):
public static void WriteColor(string s, ConsoleColor col)
{
Console.WriteLine(Util.WithStyle(s, "color:" + col.ToString()));
}or as part of dumping:
public static T DumpColor<T>(this T obj, ConsoleColor color)
{
Util.WithStyle(obj, "color:" + color.ToString()).Dump();
return obj;
} -
Itsey commented
You can do this with an extension in MyExtensions -
public static void CWColour(string s, ConsoleColor col) {
Util.RawHtml("<font color='"+col.ToString()+"'>"+s+"</font>").Dump();
} -
Alan Hemmings commented
Sweet! That'll work well for what I need, cheers, Alan
-
There is currently support for highlighting text (one color only): Util.Highlight ("Hello").Dump();