tags:

views:

620

answers:

9

I am using reflector disassembly as a quick way to convert some vb.net to c# and am hitting some problems with certain VB-isms:

  • Conversions
  • Strings
  • Information.IsNothing

When trying to compile the converted code, I need to find and change all of these and more.

Any tips on converting vb.net to C# in a clean way?

+3  A: 

http://converter.telerik.com/

Darren Kopp
+1  A: 

Have you tried any code converters? Telerik has one.

David Mohundro
+6  A: 

In my experience, .NET Reflector is the best way to convert between VB.net/C# even if you've got the source code.

  • Conversions? Could you elaborate?
  • Strings work the same, just be sure to convert slashes to double-slashes ("C:\" becomes "C:\\" or @"C:\") and to use the standard methods rather than Mid and Instr and whatnot
  • Information.IsNothing(obj) is equivalent to obj == null
rpetrich
A: 

Have you tried C-Sharpener For VB ?

http://www.elegancetech.com/csvb/csvb.aspx

Rismo
+1  A: 

I've been using this one for years: Developer Fusion

It's mainly for quick little code snippets that I have in VB that I want to convert to C# quickly. It's not perfect, but it's ok.

Scott
+1  A: 

Here's a quick comparison chart I look at when I switch between languages.

Cookey
A: 

Most of the Strings and Conversions methods can be used from C# by importing the Microsoft.VisualBasic namespace.

Joel Coehoorn
+1  A: 

I've tried several different converters. Surprisingly, the best one I tried is SharpDevelop. I load the file into the SharpDevelop IDE, then select convert. I haven't had a single instance of bad code. The coolest thing I use it for is translating VB.NET Win32 API pInvokes.

hectorsosajr
A: 

I have been using http://www.developerfusion.com/tools/convert/csharp-to-vb/ recently without many major problems.

Luke