Hi Joergen,
ACK, this reminds me of my favorite post from
microsoft.public.de.german.entwickler.donet.vb newsgroup:
<original post, translated>
I need help in translating a line of C# code to VB.NET. The freely
available conversion tools yielded different results...
here is the code (num2 and num1 are of type int):
num2 = ((num2 << 5) + num2) ^ num1;
Results from the conversion tools:
num2 = CInt((num2 << 5 + num2) ^ num1)
num2 = (((num2 + 5) + num2) Or num1)
</original post>
<answer>
num2 = ((num2 << 5) + num2) ^ num1
</answer>
Do I need to say more? *g*
Regards,
Mathias Wuehrmann
That's pretty funny.
And if you paste the same code into the converter I
linked to (or
http://converter.telerik.com/), we get
num2 = ((num2 << 5) + num2) Xor num1
If we grab another one at
http://www.kamalpatel.net/ConvertCSharp2VB.aspx
we get
num2 = ((num2 < 5) + num2) ^ num1
Yes, only one "<" instead of "<<" and "Xor" instead of "^".
Actually, I believe the first conversion to be the correct one -
not the one you provided. As far as I am able to read the online
documentation, the "^" character in C# means logical XOR,
whereas the same character in VB.Net means "raises a number
to the power of another number". (Please correct me if I am wrong).
Only proves my point that one needs to be able to evaluate
the output - which kind of obviates the need for such converters.
Occasionally I write something in one language, compile it, and
then use Reflector to decompile it to another language, just to see
what it looks like. That approach has its own pitfalls.
I wonder if Reflector still chokes when attempting to decompile a
function that uses On Error Resume Next?
Haven't tried that one
for a long time.
Regards,
Joergen Bech