C# 4.0: Can I use a Color as an optional parameter with a default value? [duplicate]
I’ve run into this as well and the only workaround I’ve found is to use nullables. public void log(String msg, Color? c = null) { loggerText.ForeColor = c ?? Color.Black; loggerText.AppendText(“\n” + msg); } Other possible syntax is: loggerText.ForeColor = c.GetValueOrDefault(Color.Black);