+ 1
C# Question
So I did try and look up this on the Q&A but it wouldn't search for it unfortunately. Anyways, I'm trying to learn C# and this question came up in the quiz. int a = 4; int b = 6; b = a++; Console.WriteLine(++b); The answer is 5 from the quiz but I'm rather confused as to how why. Any help would be appreciated!
3 Respuestas
+ 4
b is 6
make b = 4(a), THEN add to a
write line of b, add 1 before it's used which is 5
these are called increments and decrements. Knowing that you can probably search explanations a lil better. Thank you for searching first
+ 2
yes, sounds about right
+ 1
Awesome! Thank you so much for the help!
So just make sure I get it:
Even though b = 6, since b = a++ it would replace b = 6
Finally in the Console, since we have ++b, it basically adds the increment before moving on with the expression?