Question

i found a translator for c++ to c# , but it doesn't work. (Code2Code.net)

Test with cout

int main(int argc, char** argv)
{
cout << "Hello World";
return 0;
}

The Results becomes

public static int Main(string [] argv) 
{ 
cout << "Hello World"; 
return 0; 
} 

My Question to you, is = is it any other translator that works for C++ to C# (dont need to be free)

No correct solution

OTHER TIPS

I am not aware of any as this kind of translation would be very difficult to do. You are trying to translate code that was written in an unmanaged language into a language that is managed. Even if you were able to translate the code you would have almost every method marked as unsafe which would negate most of the benefits of moving to C# in the first place.

This seems like a bad idea - you ought to be thinking about rewriting the application from scratch.

My suggestions would be to initially use C++/CLI to port over the C++ code to a managed environment. Once working in the managed world, build new code in C# around it. If there are key areas of the existing code that are actively changing, consider porting to C# at that point.

I don't think any translation engine for C++ -> C# could do more than safe a bit of typing on boilerplate code (fix basic syntax) - as the frameworks used in C++ and C# are fundamentally different, and you will run into problems as soon as the translator has to deal with pointers arithmetics and stuff like this.

Given the complex syntax of C++ and the crazy stuff you can do with it (think Boost) I guess any translator would run into serious trouble sooner or later. See this blog post for some alternative suggestions.

Code2Code.net explicitly states

You accept that this page does only half the work.

...

In most cases, the translated code will not even compile.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow