【发布时间】:2014-02-19 15:26:45
【问题描述】:
我想知道,因为我有一个带有多个默认参数的方法
private string reqLabel(string label, byte fontSize = 10, string fontColour = "#000000", string fontFamily = "Verdana" )
{
return "<br /><strong><span style=\"font-family: " + fontFamily + ",sans-serif; font-size:" +fontSize.ToString() + "px; color:"+ fontColour + "; \">" + label +" : </span></strong>";
}
当我调用该方法时,我必须按顺序进行
reqLabel("prerequitie(s)")
reqLabel("prerequitie(s)", 12)
reqLabel("prerequitie(s)", 12 , "blue")
reqLabel("prerequitie(s)", 12 , "blue", "Tahoma")
所以我的问题是,有没有办法跳过前几个默认参数?
假设我只想输入颜色和字体系列,如下所示:
reqLabel("Prerequisite(s)" , "blue" , "Tahoma")
/* or the same with 2 comma's where the size param is supposed to be. */
reqLabel("Prerequisite(s)" , , "blue" , "Tahoma")
【问题讨论】: