问题
Can anybody help me by suggesting the name of an converter which converts C# code to Java code. Actually, I have a tool which is written in C# code and I am trying to modify it. As I have no idea about C# and .NET framework, it seems difficult to me to convert the large code by my own. I found from some web information that there exist some tools which can convert C# to Java (may not be properly, however they can). Can anybody help me by suggesting some name of those tools.
回答1:
Disclaimer: No tool is perfect.
However, if you still want to try then there are these converters available:
- CS2J
- JCLA : Convert Java-language code to C#
- Grasshopper
- CSharpJavaMerger
- Tangible Software C# to Java Converter
Not a converter but a bridge between .NET and the JVM:
- JNI4NetBridge
回答2:
You are better off doing it by hand. I've used code conversion software before, and it just mucks everything up. Sure, it corrects a few syntax differences, but largely what you'll get is just a mess of code that doesn't compile right away anyway.
With a converter you'll have to do a lot of corrections anyway. Why not take the small amount of extra time it will take to convert it by hand and end up with better code?
Even if you don't know C#, it will be better to learn it and do the conversion by hand, as I said before you will have to do it anyway. C# and Java are not too different syntactically, but as @Marc pointed out above, there are certainly gaps in the language. Simple C# is easily translated to Java, of course having to use the Java BCL instead of the .NET, which certainly have their differences. As you get into more complicated C#, there are things that have no direct equivalent.
Keep in mind, that conversion projects can be extremely time-consuming and are extremely effective at swallowing money in a business environment.
A google search will yield you some commercial options, but I'm not going to post them here, simply because I'm against that sort of thing. There are some things you just can't automatically translate.
来源:https://stackoverflow.com/questions/7029904/looking-for-the-code-converter-which-converts-c-sharp-to-java