"Jon Paal" <Jon[ nospam ]Paal @ everywhere dot comwrote in message
news:ef**************@TK2MSFTNGP04.phx.gbl...
what is vb equiv. of
++
shown in C# ?
David's answer is correct, but with the ++ (increment) and -- (decrement)
operators, you also need to be aware that the ++ and -- operators each come
in two versions, prefix and postfix, that affect operation in complex
expressions.
int i = 5;
i++; and
++i; do exactly the same thing, add 1 to the current value in the variable
i.
i--; and
--i; also do exactly the same thing, subtract 1 from the current value in i.
So, prefix vs. postfix notation makes no difference in simple expressions.
In an expression like this, however,
Assume i == 5
if (i++ 5) vs. if(++1 5).
there is a difference:
if(i++ 5) evaluates the Boolean expression based on the *current* value in
i, then adds 1 to i.
The Boolean expression is false.
if(++1 5) *first* adds 1 to i, then evaluates the Boolean expression using
the new value in i.
The Boolean expression is true.
As you didn't show the context in which you encountered the ++ in C# code, I
though you should be aware of the difference between prefix and postfix
notation.