+ 2

What is prefix and post-fix in c#? explained and detail huhu I don't understand

16th Nov 2020, 5:35 AM
Joyce
Joyce - avatar
4 Réponses
+ 8
Hi, the difference basically is that in x++ (postfix) the variable is evaluated and then 1 is added, while in ++x (prefix) 1 is added, and then the variable is evaluated As you can see in the code, the final result is the same in both cases, but the process is different It should be clarified that the same thing happens with the decrement x-- and --x, only that a unit is subtracted instead of beign added https://code.sololearn.com/czTTaQPf7VnO/?ref=app
16th Nov 2020, 5:59 AM
Mariano Fregosi
Mariano Fregosi - avatar
+ 4
You're welcome! Decrement works in a similar way, only that 1 unit is subtracted instead of being added By postfix (x--) the variable is evaluated and then 1 is subtracted, while by suffix (--x) 1 is subtracted and then the variable is evaluated, check the code to see the example https://code.sololearn.com/ci6In2BrQLr6/?ref=app
17th Nov 2020, 2:39 PM
Mariano Fregosi
Mariano Fregosi - avatar
+ 2
Mariano Fregosi thankyouuuuu!! ❤
18th Nov 2020, 5:51 AM
Joyce
Joyce - avatar
0
Thank youuuu so much, how about decrement what is it?
17th Nov 2020, 12:22 PM
Joyce
Joyce - avatar