0
c# incrementing logic
On the quiz here a = 4; b = 6; b = a++ then console.writeline(++b); was equal to 5. What is the logic here?
3 Antworten
0
When evaluated, a++ equates to a before the increment, so is equal to say
b = a; // b is 4
a += 1;
cons.write(++b) // This increments before getting the value, so 4+1=5, which is the output.
0
Check about the prefix (++n) and postfix (n++) incrementation.
a = 4;
b = 6;
b = ++a; // b = a, a = a + 1 (b = 4, a = 5)
Console.WriteLine(++b) ; // b = b + 1 = 5
0
thanks guys