Optional and Named Arguments
Give parameters defaults and call them by name.
Example
static string Box(int w, int h = 1, string unit = "cm") => $"{w}x{h}{unit}";
Console.WriteLine(Box(3));
Console.WriteLine(Box(3, unit: "m"));
Console.WriteLine(Box(h: 2, w: 4));Exercise
Named argument.
Box(w: 1, : 2)
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.