What is the difference between a++ and ++a in c#? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the difference between a++ and ++a in c#?

9th Aug 2016, 10:09 AM
rilas
3 Answers
+ 1
Simply put. a++ uses the variable and then adds one to it. ++a adds one to the variable and then uses it.
9th Aug 2016, 10:50 AM
Andreas BeEm Kvist
Andreas BeEm Kvist - avatar
0
difference between a++ and ++a is a++ automatically increase by one while ++a print first before increase
9th Aug 2016, 10:29 AM
JCrashByte
0
++a means firstly increase the value of a by 1 then read the value of a. a++ means firstly read the value of a and then increase the value of a by 1. Example : int a=5; Console.WriteLine(a++) ; //output is 5 Int b=5; Console.WriteLine(++b); //output is 6
27th Sep 2016, 9:51 PM
Jai Verma
Jai Verma - avatar