public void log(String msg, Color c = Color.black) { loggerText.ForeColor = c; loggerText.AppendText("\n" + msg); }
This leads to the error that c must be a compile time constant. I read a little about this, and most examples deal with strings and ints. I realized that I can use the colorconverter class, but I'm not sure if it will be very efficient. Is there a way to just pass the base color as an optional parameter?
public void log(String msg, String c = "Black") { ColorConverter conv = new ColorConverter(); Color color = (Color)conv.ConvertFromString(c); loggerText.ForeColor = color; loggerText.AppendText("\n" + msg); }
c # optional-parameters
DTown May 10 '10 at 16:27 2010-05-10 16:27
source share