0

Not understanding how default parameter values work

static int Pow(int x, int y=2) { int result = 1; for (int i = 0; i < y; i++) { result *= x; } return result; } static void Main(string[] args) { Console.WriteLine(Pow(6)); //Outputs 36 Console.WriteLine(Pow(3, 4)); //Outputs 81 } is the Pow method defaulting to multiplying itself by the argument value here? Cannot get my head around this! Any help is appreciated.

13th Aug 2020, 9:25 PM
XCVI P4UL
XCVI P4UL - avatar
1 Réponse