C# ->VB: Postfix Increment Operator fails

1 posts, 0 answers
  1. Larry
    Larry avatar
    1 posts
    Member since:
    Oct 2012

    Posted 04 Oct 2012 Link to this post

    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)

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

Back to Top