The developerFusion web site provides code converters that let you translate between C#, Visual Basic, Ruby, and Python.
One of the most important uses for reflection is analyzing code to figure out what it does. Once you know what the code does, you can emit new code to do the same thing in a different programming language. That’s what these code converters do. (Although right now they seem to be having trouble.)
The site has a tools page with links to free web-based tools that convert between C#, Visual Basic, Ruby, and Python. The tools are:
- Convert C# to VB.NET
- Convert C# to Python
- Convert C# to Ruby
- Convert VB.NET to C#
- Convert VB.NET to Python
- Convert VB.NET to Ruby
The results are pretty good, although the languages do not provide exactly the same features so the results aren’t necessarily perfectly equivalent. For example, Visual Basic’s Select Case statement is more flexible than C#’s switch statement, so the tools cannot always perform a round trip conversion from Visual Basic to C# and back. For specific examples, it converts Case 0 To 9 into a series of 10 C# case statements and it cannot handle statements such as Case Is < 0, Is >= 30. (It should probably convert these kinds of Select Case statements into sequences of if-then-else statements instead if trying to use a switch statement.)
Overall, however, the results are reasonably good, can give you a big head start if you need to translate a lot of code, and are free.