Sunday, March 11, 2012

Converting VB.Net to C#

If you are working at a company which has been developing .Net applications for any length of time, odds are that you have at least 1 VB.Net Application in your organization.  

If you are like most C# developers, you probably prefer to work in C# rather than continue to maintain the application in VB.Net.  

One of the main problems that I have found in working with VB.Net applications has been that it supports many of the constructs of Visual Basic 6 (VB6).  Therefore, if your VB.Net application was upgraded from VB6 at some point in time, there is probably a lot of leftover Non-.Net type of code interspersed throughout the code base.  Rather than continue to maintain these remnants of VB6 within the code base, it is usually much better to migrate to a complete .Net solution.  One of the best ways to achieve that is to convert it completely over to C#.

There are numerous code converters on the web which offer to translate content from VB.Net to C# for you.  Probably the most well-known VB.Net to C# converter is the online version maintained by Telerik: http://converter.telerik.com/

However, if you are attempting to convert a reasonably sized VB.Net project, converting on a file-by-file basis is probably not sufficient.  Instead, you will probably want to utilize a tool that can convert an entire Visual Studio Solution or Visual Studio project for you.

Two of the more affordable VB.Net Converter utilities I discovered are:
  1. VBConversions: http://www.vbconversions.net/home.htm
  2. Instant C#: http://tangiblesoftwaresolutions.com/Product_Details/Instant_CSharp.html
The main limitation with the VBConversions tool is that it is unable to convert Web Site projects.  It is only able to convert Web Application projects that are associated with a .vbproj file.  This limitation alone was sufficient for me to choose the alternative Instant C# for my conversion needs.

Instant C# supports all types of solution and project conversions.  The overall accuracy of the conversion is excellent and whenever I encountered issues with aspects of the conversion process, the support staff was extremely helpful in resolving the issues and providing me with an updated version of the tool for download (sometimes within a matter of hours or days).

Overall, I have had great success with converting my VB.Net to C# projects using Tangible Software Solutions' Instant C# product and I will very likely continue to utilize it for all of my future VB.Net to C# conversion needs.  

If you have an upcoming VB.Net to C# conversion project, you should definitely give Instant C# a spin and see if performs as well for you as it did for me!


2 comments:

  1. Hi,

    I tried the vbconversions tool for converting my solution which has one .vbproj for desktop application. But few code line are not getting converted very well. For example:

    1. Dim str as string = 10
    2. parameterized properties
    3. function name or property name set to value instead of return statement

    are these well supported by the Instant C# tool.

    ReplyDelete
  2. Good guide for converting vb6 to c#. Useful information.

    VB6 to C#

    ReplyDelete