Use the automatic code converters at developerFusion to convert C# code into Visual Basic, Ruby, and Python

[code converters]

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:

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.

Follow me on Twitter   RSS feed   Donate

This entry was posted in programs, reflection, syntax and tagged , , , , , , , , , , , , , , , . Bookmark the permalink.

7 Responses to Use the automatic code converters at developerFusion to convert C# code into Visual Basic, Ruby, and Python

  1. Angel says:

    Very good idea, at this moment it’s great for me. As I have not been able to evaluate developerFusion since the translation does not work at this moment, I have searched for alternatives and works very well for me. Thank you

  2. Rajat says:

    I have tried to convert a simple “Hello World” code of C# into python but nothing happened. It is just showing processing for last 12 hours.

    Any solution?

  3. dani kataya says:

    is there any good convertor for c++ to c#?
    and for fortran 77 fixed format to c#?

    • RodStephens says:

      There may be such translators, but I don’t know of any. The C++ –> C# translation shouldn’t be too hard. Translating from Fortran 77 will be harder.

  4. rafael says:

    saludo a todos
    necesito convertir este codigo esta en C# a Python

    struct tipoPersona
            public string nombre;
            public char   inicial;
            public int    edad;
            public float  nota;
    • RodStephens says:

      I would probably use a class like this:

      class Persona():
          def __init__(self, nombre, inicial, edad, nota):
              self.nombre = nombre
              self.inicial = inicial
              self.edad = edad
              self.nota = nota

      Or you could use a named tuple.

      See this post for some discussion: C-like structures in Python

Comments are closed.