0
I don't understand this simple C# code
int a = 4; int b = ++a; if ( b > 5) { Console.Write(b); }else{ Console.Write(a) ; //output 5 b = 5 which is not higher than 5, so why is the program outputing the value of b?
2 Answers
+ 7
a is also 5
b = ++a <- this increments the variable a by 1 then assigns a's value to b as a result both variables are 5.
Note: the else statement is executed, (Console.Write(a))
+ 1
Thank you Jay. I get it now.