vb.net C # code conversion Tool-2 (I collect and organize)

Source: Internet
Author: User
Tags abstract tree

Excerpted from the Computer World newspaper, September 12, 2005, Phase 35th C9

The authors introduce the installation and use of several tools for converting between C # and vb.net projects, as well as their respective advantages and disadvantages.

Perhaps you need to migrate your previous vb.net projects to C #, or, conversely, not every. NET programmer is proficient in both C # and vb.net. Maybe you need to read the sample code written in vb.net or the shared source, but you're just familiar with C #, and you need a transformation software to help you do your work quickly and accurately.

The following are the current popular conversion software listed the installation, use of methods, as well as their respective advantages and disadvantages, hope to help readers find their own software faster, and deploy, use, solve the problems in the work as soon as possible.

vb.net conversion to C #

1. VB.net to C # Converter (download address: http://www.vbconversions.com/)

VB.net to C # Converter is an offline conversion software that is simple to install, provides a trial version, and never expires, but the trial version can only translate no more than 600 lines of source engineering. VB.net to C # Converter The user's vb.net project to be rewritten in the C # language, while the variable name and comment line are preserved. It has complete functionality, provides professional reporting generation tools, and can generate error records for errors in the conversion process, and provides error analysis and recommendations for modification on this basis. In a word, it is a fully functional conversion tool for users to consider.

It provides conversions of various types of engineering, including Windows Forms Engineering, Console Engineering, Windows Control Library, Web Control Library, Web services engineering, and Windows Service Engineering. Offers multiple forms of conversion, including single engineering, multiple projects, interactive code conversions, and command-line conversions. Most of the VB functions can be converted to the corresponding C # function, and annotations can also be very good conversion. You can use the wizard and provide online Help. The conversion accuracy rate is as high as 99%.

However, it does not support Chinese, Chinese annotations will generate garbled. The full version needs to be purchased.

2. Online vb.net program converted to C #

The online conversion URL is http://www.developerfusion.co.uk/utilities/convertvbtocsharp.aspx. Easy to use, and free of charge. It is only currently in beta, the conversion of the program error more, and the converted code does not include comments, this is because the converted code before returning, first translated into an abstract tree, and the current tree-like structure to ignore the annotations.

C # conversion to vb.net

1. C # to VB.net translator implement a single file conversion

This is an online solution using Web services, and the transformation interface is simply no longer easy. All you have to do is copy your C # code, paste it into the input box, and then click the Translate (Translate) button. It can be used for free, but must be converted online (URL is http://authors.aspalliance.com/aldotnet/examples/translate.aspx). Now, it can't handle tags or any HTML, so your C # code must be pure C #. Also, it can only convert one file and cannot convert the entire directory.

2. Using Web services proxies to convert files in the entire directory

Based on the above web Services,xml for ASP.net developers provides a solution that enables the entire directory transformation, you can see its sample code and solution at the following URL: http://www.xmlforasp.net/ Codesection.aspx?csid=44. This conversion can be used free of charge and can transform the entire directory. The solution on the XML for ASP.net developers actually calls the C # to vb.net translator Web Services, but extends the C # to vb.net translator functionality, but the deployment is cumbersome and requires Build the project and add the reference.

In order to facilitate a better understanding of the XML for ASP.net developers solution, here is a further elaboration of the implementation steps of the solution. The specific steps are as follows:

Create a new C # engineering CONVERTC for ASP.net Web services.

Add Web reference Http://authors.aspalliance.com/aldotnet/examples/csharptovbtranslator.asmx?WSDL to the project. The reference is automatically named Com.aspalliance.authors.

Add the Csharpfiles folder under the project root, and save the C # file that needs to be converted as a. txt text file under the folder.

Add a new Web Form convertctovb.aspx, and add a form with the ID csharptovbcon-verterfrm in it.

Double-click convertctovb.aspx to generate ConvertCtoVb.aspx.cs files. The file first instantiates the Csharptovbtranslator class in the Web reference com.aspalliance.authors and gets the form with ID csharptovbcon-verterfrm as the Code container. Each file in the Csharpfiles folder is then read separately for the code that needs to be converted, the Translatecsharptovb () method in the Web service is invoked to convert, and the converted code is finally exported to the form code container of the page.

Set convertctovb.aspx as the initial file and run the project, all files under the Csharpfiles folder can be converted from C # to vb.net.

3. Using C # to vb.net Converter

The software download address is http://csharpconverter.claritycon.com/. The software provides online and offline two ways to achieve C # to vb.net conversion, and off-line version of the installation is simple, easy to use. But in some cases the conversion is not very accurate, in fact these situations are also prevalent in some other conversion tools. This requires us to understand the differences between some C # and vb.net, and here's a list of several situations that require manual modification. It's important to note that these are the parts that we should focus on when we use other conversion software to automate the conversion.

Reference comparisons and value comparisons in C # use the "= =" keyword, while vb.net uses the "is" keyword as a reference comparison and uses "=" to compare values, so a conversion error occurs when using "= =" in a C # program to make reference comparisons. The method of modification is: After the conversion, all reference comparisons are replaced with "is" with "=".

Both character connectors and addition operators use "+" in C #, so using "+" as a character connector in C # causes the character connector "+" in C # to be converted to the character connector "&" in vb.net correctly. The modified method is: After conversion, manually modify the character connector "+" to "&".

Because vb.net is case insensitive, a duplicate name may appear after C # conversion. The method of modification is to manually modify the name of the appropriate word.

Note Sometimes cannot be loaded to the correct location. The method of modification is to manually adjust the annotation to the correct position.

Manual conversion

The above mentioned is the use of tools to achieve C # and vb.net conversion between, but in time and effort allowed, you can completely through manual modification to achieve C # and vb.net between the conversion. Of course, the benefits are obvious, first you can fully understand the differences between the grammar and structure of the two languages, and can learn another language in one language. Second, it is also possible to effectively avoid the errors that the above mentioned conversion software might produce in certain circumstances. Because, although we can use automation tools to achieve conversion, improve our productivity, but so far there is no one tool to achieve 100% error-free conversion. Because most of the conversion software is based on literal and syntactic conversions, rather than based on the conversion of the program logic, so the program conversion process may be because the program logic is not understood by the error, as mentioned above, so the use of automated tool conversion we still have to test and a small amount of modification, while understanding the certain C # And the vb.net of the grammar and the difference between them is very good for us. If using manual conversion, then C # and vb.net between the grammar table may be useful to you, you can refer to the following Web site: http://www.harding.edu/USER/fmccown/WWW/vbnet_csharp_comparison.html.

(with the next, the effect is good, a single unit transformation is not bad, but vb.net to C # conversion has many obvious errors,
Such as
IList List;
List (index)--> to list (index) instead of List[index]
Tostring,tolower,getnextentry
will not be converted to add ()

=========================================================

About vb.net C # code conversion tools

1.http://www.kamalpatel.net/(most commonly used, but not normal conversion for 16-in-binary int)
Online version: VB.net => C # c#=>vb.net
Offline Version: C#=>vb.net
2.http://csharpconverter.claritycon.com/(recommended!) It's a very good one, it's almost never too big a problem. )
Online version: C#=>vb.net
Offline Version: C#=>vb.net
3.http://www.ragingsmurf.com/
Online version: C#=>vb.net
4.http://aspalliance.com/
Online version: C#=>vb.net
5.http://developerfusion.com/
Online version: VB.net => C # c#=>vb.net

(goto: http://happy555.cnblogs.com/archive/2005/07/05/186745.html)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.