This review covers two products, Instant C# and Instant VB.
I will switch between the two, and as you will see they are nearly mirror
images of one another. Figure 1 shows the main user interface for Instant C#.
Figure 1: Instant C# User Interface
The tool is fairly intuitive to use. As you might guess by
looking at Figure 1, it supports converting complete VB projects (1.x or 2.0)
to C#. A simple way to test this feature is to open up one of the ASP.NET
Starter Kits in VB (or VB Starter Kits)
and convert it to C#. I tested the product using several different starter
kits and found that it did a good job overall, but there were some things it
was unable to convert without some developer interaction. For instance,
Resource files required some manual work to get working in C# after converting
from VB. On the whole, however, the projects were converted about 99% of the
way and, of the ones I tested, compiled on the first try. Figure 2 shows some
advanced options that are available for the conversion process.
Figure 2: Instant C# Conversion Options
After converting a project, the tool displays the number of
lines of code converted, how long it took (14 seconds for the VB Card Game
Starter Kit on my machine), and a list of warnings and errors. Comments are
inserted into the converted code showing warnings and TODO items, with a
summary report provided to make it easy to find and correct anything that needs
to be manually converted (which is to be expected in any significant, real
world project). Figure 3 shows the end result after converting the VB Card
Game Starter Kit.
Figure 3: Post-Conversion Summary
In addition to full project support, the tool also supports
conversions at the snippet level, which is its most useful feature to me,
personally. When writing a demo for an article or presentation, I typically
prefer to write it in C# first, and then convert if dictated by the audience.
I am capable of doing the conversion manually, but it is a time-consuming,
tedious process. Instant VB lets me take my C# code samples and immediately
convert them into VB code, complete with support for 2.0 constructs like
Generics. As an example, consider this article on Generics in C#. Its
Listing 5 shows an example of a Stack class that uses Generics, which is
implemented in C#. To convert this into VB for use in a VB library, simply
cut-and-paste the code into Instant VB's Snippet Converter, with results as
shown in Figure 4.
Figure 4: Instant VB Snippet Converter
The result is VB code that works immediately, saving me a
few minutes' worth of conversion and (quite likely) some errors on my part in
the conversion process. These minutes add up quickly when you add up all of
the demos in a presentation, article, or book, not to mention the times when a
solution found on the Internet is not in one's language of choice and needs to
The Folder Converter utility simply accepts a source folder
and a target folder, and will convert all C# (or VB) files in the source folder
into VB (or C#) and place the results in the target folder. This is useful if
you wish to convert a bunch of files that are not part of a project, or if you
wish to convert a large project one folder at a time. Since non-WAP web sites
in Visual Studio 2005 are simply folders, the Folder Converter is the tool of
choice to convert ASP.NET web sites. It will convert all ASP.NET pages,
App_Code files, etc. in the process.
The last tab, ASP.NET Snippets, supports converting ASPX
pages which include inline VB (or C#) code in them. This would have been quite
useful to me a few years ago when I wrote the ASP.NET Developer Cookbook with
other ASPAlliance authors. All of its examples used inline ASPX pages to avoid
the need for readers to have Visual Studio (since the popular Web Matrix tool
did not use code-behind files). Since all examples were offered in both VB and
C#, a lot of manual conversion went into the effort. With Instant VB, a recipe
like 0307 in C# could be converted to VB in a couple of seconds, as you can
see from Figure 5.
Figure 5: Instant VB ASP.NET Snippet Converter
One general note about code conversion - it will be rare in
a real world application that any tool will successfully convert a large real
world application from one language to another without any developer intervention.
This is because the VB and C# teams are both trying to differentiate their
languages and add value to their languages, often in ways that have no
equivalent in the other language. A good example of this is the yield keyword
in C#, which does not exist in VB. In order to write similar code in VB, one
must rewrite not just the method where yield is found, but also the callers of
that method, resulting in complexities that may be best left to real
programmers to convert. With that said, I have found the Instant C# and Instant
VB products to be very robust, easy to use, and effective in my own use of
these products. The authors of these products share some of their insights
into the Art
of Conversion Between VB.NET and C# on their website.