Question regarding the C# ++ (right placed) operator.
As the left placed ++ operator, for example, ++var, (say holding an int value of 1) will increment by 1 before any other computation takes place (example value of 1 will become 2 after expression is executed and result displayed).
Can anyone explain the difference between the left placed operator and the right placed operator? (var++) as it does not seem to increment even after the expression is executed as it is supposed to do. Here is some sample code:
int var1, var2 = 5, var3 = 6;
var1 = var2++ * --var3;
Console.WriteLine(" {0} ", var1);
Console.ReadKey();
This is just 5 x 5 due to the decrement of var3 but without the decrement it is 5 x 6 and var2++ appears to have no effect other than the value of 5 it carries. If anyone can shed light on this topic I would be grateful. Thanks.
***Issue solved. A lot of great answers and input guys, was hard trying to decide what answer to accept but you are all winners here! Thanks again for the help! =)