Odd conversion for C# increment (++) operator to VB

1 posts, 0 answers
  1. David McClelland
    David McClelland avatar
    9 posts
    Member since:
    Oct 2012

    Posted 19 Oct 2012 Link to this post

    Hi there,

    We recently used the Telerik code converter for some C# code (don't ask my why the original author did it this way, "clever" code like this can get you in trouble) - it's part of a convoluted loop, but here are the relevent 2 lines of code:

    int i = 1;
    string s = Convert.ToString(i++);

    to VB.NET:

    Dim i As Integer = 1
    Dim s As String = Convert.ToString(System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1))

    That didn't produce the expected results      :-)    

Back to Top