开发者

Convert VB.NET To C# [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

Convert VB.NET code开发者_如何学JAVA to C#

Hey,

I'm looking for a powerfull tool who can convert & C# code to VB.NET or vice-versa.

I've tried some websites but they are not very good.

Any ideas ?

Thanks


I have used .Net Reflector. Just load the DLL and select the language C#, VB etc.

See http://reflector.red-gate.com/download.aspx


The two most popular ones are developerFusions and teleriks:

  • http://www.developerfusion.com/tools/convert/vb-to-csharp/
  • http://converter.telerik.com/

Sometimes you will have to hand convert certain parts of the converted code that the converters have trouble understanding but on the whole they do a large part of the heavy lifting for you.

One example is that vb.net uses array indexes as () whereas c# uses []. For some reason I have seen the developerFusion get confused and leave these as () in the c# code which confuses the compiler.

I mostly use this for quick translations of code when I am answering forum questions and the op has specifically requested a vb.net answer. I just find it easier to code it in c# and then convert it.

If you have a very large project then you might find it tedious to convert each of the individual pages. In this case you might (I haven't actually tested this) find a way to convert the code more quickly by using the #develop IDE. I only say this as the developerFusion online converter is actually powered by code from this tool.

  • http://www.icsharpcode.net/OpenSource/SD/

Another thing to remember, as has been mentioned elsewhere in this thread, is that its entirely possible to mix and match languages within a single project. The only restriction to my knowledge is that you can only have one language per folder. This is to do with the way that the .net code is compiled. By default each folder is compiled into its own assembly.

If you really need to mix and match on the same page I think you could make a usercontrol to contain the code for one language and put it onto a different languages page.


You've both online- and offline solutions at your disposal.

A very popular online converter: Developer Fusion's Converter

Reflector has for long been the most popular offline source inspector. It allows you to view any assembly in the language of your choice. However, recently they changed and it is now no longer free.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜