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

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

0 Answers 49 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.
David McClelland
Top achievements
Rank 1
David McClelland asked on 19 Oct 2012, 03:41 PM
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      :-)    

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