0

Can anyone explain me how does this code works?

static void Main(string[] args) { int a = 4; int b = 5; int c = 2; Console.WriteLine(Func(c, b)); } static int Func(int a = 3, int b = 7, int c = 6) { return a + b * c; }

10th Apr 2018, 8:11 AM
Dauren
Dauren - avatar
6 Answers
+ 1
Func takes 3 arguments. If some is not passed to function then their values are a=3 b=7 c=6. In main you pass only 2 arguments then Func has: a=2,b=5,c=6.
10th Apr 2018, 8:33 AM
Bartosz Pieszko
Bartosz Pieszko - avatar
+ 1
10th Apr 2018, 9:51 AM
Bartosz Pieszko
Bartosz Pieszko - avatar
0
Bartosz Pieszko, so variable "a" takes value 2 from variable "c" then argument "c" takes 6 value from optional parameter "c"?
10th Apr 2018, 9:10 AM
Dauren
Dauren - avatar
0
Thank you very much!
10th Apr 2018, 9:53 AM
Dauren
Dauren - avatar
0
32?
1st Oct 2018, 6:45 PM
SailarmoonKS
0
yes
1st Oct 2018, 6:56 PM
Dauren
Dauren - avatar