我开始利用 .Net 4.0 中的可选参数
我遇到的问题是当我尝试声明 System.Drawing.Color 的可选参数时:
public myObject(int foo, string bar, Color rgb = Color.Transparent)
{
// ....
}
我希望 Color.Transparent 成为 rgb 参数的默认值。问题是,我不断收到此编译错误:
'rgb' 的默认参数值必须是编译时常量
如果我只能将原始类型用于可选参数,那真的会破坏我的计划。