Click here to Skip to main content
15,883,749 members
Articles / Programming Languages / C#

Why Does x = ++x + x++ Give Me the Wrong Answer?

Rate me:
Please Sign up or sign in to vote.
4.79/5 (63 votes)
11 Nov 2021CPOL4 min read 95.5K   20  
When they first meet them, developers are often tempted to play with pre- and post- increment operators. Then they get confused, because they don't do what is expected. Or ... do they?

Views

Daily Counts

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
CEO
Wales Wales
Born at an early age, he grew older. At the same time, his hair grew longer, and was tied up behind his head.
Has problems spelling the word "the".
Invented the portable cat-flap.
Currently, has not died yet. Or has he?

Comments and Discussions