This is a migrated thread and some comments may be shown as answers.

C# ->VB: Postfix Increment Operator fails

0 Answers 42 Views
Code Converter
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Larry
Top achievements
Rank 1
Larry asked on 04 Oct 2012, 02:27 PM

The C# increment operator does not translate to VB correctly. 
x++ is a postfix increment operation. The result of the operation is the value of the operand before it has been incremented.

y = x--;  
Converts to...
y = System.Math.Max(System.Threading.Interlocked.Decrement(x),x + 1)
Correct.

y = x++; 
Converts to...
y = System.Math.Max(System.Threading.Interlocked.Increment(x),x - 1)
WRONG!
should be
y = System.Math.Min(System.Threading.Interlocked.Increment(x),x - 1)

Tags
Code Converter
Asked by
Larry
Top achievements
Rank 1
Share this question
or