Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Total Newbie ~~

Status
Not open for further replies.

williamwaihocheung

Programmer
Oct 14, 2007
4
CA
hi guys ~ I have a stupid question hope you guys dont think it's silly..


what's the difference between a ++X and a X++?

if i say X = to 5

what will be the result?

 
If X = 5 then:


1.
Console.WriteLine( ++X);
Console.WriteLine( X);

This will print: 6 and 6


2.
Console.WriteLine( X++);
Console.WriteLine( X);

This will print: 5 and 6

Google is your friend: Here is what MSDN has to say:

The first form is a prefix increment operation. The result of the operation is the value of the operand after it has been incremented.

The second form is a postfix increment operation. The result of the operation is the value of the operand before it has been incremented.


The link to the full article:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top