0

Optional Arguments

this is an example for Optional Arguments lesson it seems that everybody easily can understand it but I cant this is about an hour that I'm thinking about it and reading people's comments but I still can find out how this code is working I think im overthinking about a simple code right? thx. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static int Pow(int x, int y=4) { int result = 1; for (int i = 0; i < y; i++) { result = result * x; } return result; } static void Main(string[] args) { Console.WriteLine(Pow(3)); } } } is there any difference between the first and the second "result" in this part? (result = result * x)

12th Jan 2019, 9:14 PM
TOMMY
TOMMY - avatar
2 odpowiedzi
+ 2
result = result * x , means that the new value of result is equal to previous value multiplied by "x". In this case it's 3 ^ 4 = 81. Hope it helps you. https://code.sololearn.com/c2Z1FSTXBiIh/?ref=app
12th Jan 2019, 9:29 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 1
You are welcome 😉
12th Jan 2019, 10:29 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar