0
Can someone help me to understand this code
int a = 4; int b = 6; b = a++; Console.WriteLine(++b); The output is 5 I just canât workout how it gets that output
6 Answers
+ 3
Sham XR you're confusing pre with post b= a++ is b =4, a =5 and ++b = 5
0
a=4
b=6
b=a++ = 4++= 5.
0
console. writeLine(++b) = ++5 =5
0
the program execute the expression from right to left.
a=4++ means 1+4=5
but a =++4 means 4+nothing =4
0
thanks I understand it now I had trouble with it because of the b = 6
0
i myself confused because he said the answer is 5