calling a method with multiple default values

c#, methods

Solution

Yes, it is possible with explicit naming:

reqLabel("Prerequisite(s)" , fontColour: "blue", fontFamily: "Tahoma")

Just note that named arguments should always be the last ones - you cannot specify positioned arguments after named. In other words, this is not allowed:

reqLabel("Prerequisite(s)" , fontColour: "blue", "Tahoma")

Problem

i was wondering, because i have a method with multiple 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 it i have to do it in order ``` reqLabel("prerequitie(s)") reqLabel("prerequitie(s)", 12) reqLabel("prerequitie(s)", 12 , "blue") reqLabel("prerequitie(s)", 12 , "blue", "Tahoma") ``` so my question is, is there any way to skip the first few default parameters? Let's say i want to input only the colour, and the font-family like this: ``` 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") ```

Original source