Does incrementing the operator stores the value in the variable? | SoloLearn: Learn to code for FREE!

+3

Does incrementing the operator stores the value in the variable?

like a=9; Console.WriteLine(a++); will change the value of a to 10?

1/2/2020 9:11:54 AM

RAJAN RAI

3 Answers

New Answer

+4

As a++ is same as a=a+1 so yes it will change it's value. Position of "++" determines whether the value of 'a' must be used before or after the incrementing it a++ means use and then change ++a means change and then use

+3

I guess yes it does.

+2

Yes, It does. But in your case value will be printed first before it is increased. Means, First value of ( a ) will be printed Then it will become 10 To print the value of ( a ) as 10 you should use: Console.WriteLine(++a)