#593 – Using Named Arguments
May 29, 2012 4 Comments
Traditionally in C#, arguments must be passed in to a method in the same order in which they are defined in the method’s declaration.
public void DoATrick(string trickName, int numTimes)
Dog kirby = new Dog("Kirby"); kirby.DoATrick("Fetch", 158);
You can, however, change the order of the arguments by preceding each value by the name of the parameter, with a colon (:) following each name.
kirby.DoATrick(numTimes: 5, trickName: "Run around me");