I was interested because I have a method with several default parameters
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>";
}
and when I call the method, I have to do this to
reqLabel("prerequitie(s)")
reqLabel("prerequitie(s)", 12)
reqLabel("prerequitie(s)", 12 , "blue")
reqLabel("prerequitie(s)", 12 , "blue", "Tahoma")
so my question is: is there a way to skip the first few parameters by default?
Let's say I want to introduce only the color and font family as follows:
reqLabel("Prerequisite(s)" , "blue" , "Tahoma")
reqLabel("Prerequisite(s)" , , "blue" , "Tahoma")
source
share