Click here to Skip to main content
15,868,016 members
Articles / .NET

.NET Code Conversion - Convert Your Code

Rate me:
Please Sign up or sign in to vote.
4.96/5 (62 votes)
4 Feb 2012CPOL6 min read 748.1K   107   56
This post explains how to convert the code in .NET

Table of Contents

Introduction

This post explains how to convert the code in .NET.

Background

In a lot of programming forums, you can find some questions related to code conversion. For example, an enquirer asks a question in VB.NET & answerer(s) posting solution(s) but unfortunately it's in C# (instead of VB.NET). After seeing the solution(s), the enquirer replies something like "My project developed in VB.NET but your solution is in C#, blah blah blah ....". Then answerer's reply will be something like "You can convert the code, search in web for code convertors". But sometimes, the enquirer wants an offline convertor (Reason may be the Internet connection). So this simple post would be useful for them.

SharpDevelop

It's an Open Source Development Environment for .NET. You can download the tool here. Also take a look at the features of SharpDevelop & they have a forum so if you have any questions, that will help you. Using this, you can convert the code.

Supported Programming Languages

For Code conversion, currently SharpDevelop supports the following languages:

  • C#
  • VB.NET
  • Boo
  • Python
  • Ruby

Code Conversion

After installation, create a blank project & write some code. Here, I have written some C# code. Now click Tools menu, select option Convert code to & select the language which you want (Here, I have selected VB.NET). That's all. Now the code has been converted & generated in a new file.

C# Code

C#.NET Code

VB.NET Code

VB.NET Code

Online Convertors - Alternative Way

Offline Convertors

Addin(s)/Web Services

Addins created from online code conversion Web services.

A Visual Studio Add-In That Converts C# Code To Visual Basic

Before Conversion

Make sure your code is working, for example if you miss single {or any other things, then the conversion will show you syntax error(s) instead of output. See below:

The converter uses SharpDevelop's NRefactory to perform the conversion. For the conversion to work properly, you have to paste a full class or source code file because we don't do "magic" RegEx's or string replacement - our code converter uses a full blown parser, and that's why the source code must be valid.

Even convertors won't convert the code 100%. The main reason is some features doesn't exist in particular language, see the Further reading section. Even Commercial tools convert the code only 99% or probably you need to code rewrite.

Remember, if you want to convert VB6 to C#, don't go with that option. Convert VB6 to VB.NET using VS wizard & make sure the code is working and then do VB.NET to C#

Code Rewrite

Read about Rewrite (programming) & check this post Rewrite Code From Scratch which contains good & bad reasons to avoid/code-rewrite.

Multiple Programming Languages in .NET

Alternatively, you can use both code in your application if you don't want to convert the code, see below:

VB6 to .NET

VB6 is obsolete by a decade and was always horrible.[^]
Why is anyone still using VB6 in 2011 ? Self loathing ? A dinosaur who refused to move with the times ?[^]
VB6 is dead and was always a joke. Why are you using it ? [^]

In VS, you have a wizard to convert VB6 to VB.NET. AFAIK, there is no freeware to convert VB6 to VB.NET. BTW, even if you convert the code using convertor, it won't do that 100%, you need to make some/more manual changes. Particularly if you used any 3rd party components, then it will be a big headache because they (3rd parties) are always changing things in every version, so the VB6 code will show syntax error(s) in VB.NET. Check this bunch.

ASP to .NET

Java to .NET

  • Java Language Conversion Assistant 2.0 - Java Language Conversion Assistant is a tool that automatically converts existing Java-language code into Visual C#
    Retirement of J# language and Java Language Conversion Assistant from future versions of Visual Studio Since customers have told us that the existing J# feature set largely meets their needs and usage of J# is declining, Microsoft is retiring the Visual J# product and Java Language Conversion Assistant tool to better allocate resources for other customer requirements. The J# language and JLCA tool will not be available in future versions of Visual Studio. To preserve existing customer investments in J#, Microsoft will continue to support the J# and JLCA technology that shipped with Visual Studio 2005 through to 2015 as per our product life-cycle strategy.
  • Janett - Java to .Net Translator - Janett translates Java syntax, constructs and calls to Java libraries to C# / .NET counterparts.
  • CSharpJavaMerger Framework - Free and open source C# and Java conversion tool.
  • Java 2 CSharp Translator for Eclipse - That tool makes it possible to automatic translate Eclipse Java projects into Visual Studio projects. Generated code can be directly compiled and executed without any user modification.

PHP to .NET

Delphi to .NET

  • Delphi.NET - is a collection of Open Source tools and code components that enable Borland Delphi (version 5 or higher) to communicate with the Microsoft .NET-Framework.

C++ to .NET

ColdFusion to .NET

Videos

Further Reading

History

This article was originally posted at http://thatraja.blogspot.com/feeds/posts/default

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Team Leader
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionMy Vote of 5 Pin
Member 111054908-Apr-15 20:02
Member 111054908-Apr-15 20:02 
GeneralMy vote of 5 Pin
Tom Marvolo Riddle3-Apr-14 18:26
professionalTom Marvolo Riddle3-Apr-14 18:26 
GeneralMy vote of 5 Pin
Hassan Oumar Mahamat10-Mar-14 7:35
professionalHassan Oumar Mahamat10-Mar-14 7:35 
GeneralMy vote of 5 Pin
Maciej Los23-Dec-13 6:09
mveMaciej Los23-Dec-13 6:09 
QuestionPages not found Pin
Mohamad M. Mohamad2-Dec-13 3:43
Mohamad M. Mohamad2-Dec-13 3:43 
AnswerRe: Pages not found Pin
thatraja2-Dec-13 4:19
professionalthatraja2-Dec-13 4:19 
QuestionMy Vote of 5 Pin
Hiren solanki20-Oct-13 23:22
Hiren solanki20-Oct-13 23:22 
QuestionMy vote of 5 Pin
abbaspirmoradi16-Sep-13 8:48
professionalabbaspirmoradi16-Sep-13 8:48 
QuestionIt does convert only new solutions ! Pin
Renganathan Iyengar16-May-13 22:48
professionalRenganathan Iyengar16-May-13 22:48 
GeneralMy vote of 5 Pin
Tarek Elqusi24-Jan-13 21:06
professionalTarek Elqusi24-Jan-13 21:06 
GeneralMy vote of 5 Pin
yeng thao19-Jan-13 2:02
yeng thao19-Jan-13 2:02 
GeneralMy vote of 5 Pin
Abhinav S7-Jan-13 19:47
Abhinav S7-Jan-13 19:47 
QuestionC# to VB.net Code Convertor Pin
carlmalden28-Jul-12 11:30
carlmalden28-Jul-12 11:30 
QuestionJust noticed something... Pin
Sander Rossel15-Jul-12 1:19
professionalSander Rossel15-Jul-12 1:19 
AnswerRe: Just noticed something... Pin
thatraja20-Jul-12 10:44
professionalthatraja20-Jul-12 10:44 
GeneralRe: Just noticed something... Pin
Sander Rossel22-Jul-12 11:14
professionalSander Rossel22-Jul-12 11:14 
GeneralMy vote of 5 Pin
Carsten V2.07-Jul-12 19:39
Carsten V2.07-Jul-12 19:39 
GeneralMy vote of 4 Pin
fredatcodeproject7-Jun-12 23:13
professionalfredatcodeproject7-Jun-12 23:13 
GeneralMy vote of 5 Pin
Sergey Alexandrovich Kryukov5-Jun-12 17:29
mvaSergey Alexandrovich Kryukov5-Jun-12 17:29 
GeneralMy vote of 5 Pin
Fahd-Harb9-Apr-12 5:12
Fahd-Harb9-Apr-12 5:12 
GeneralMy vote of 5 Pin
Espen Harlinn8-Apr-12 0:56
professionalEspen Harlinn8-Apr-12 0:56 
GeneralMy vote of 5 Pin
Sandesh M Patil2-Apr-12 22:40
Sandesh M Patil2-Apr-12 22:40 
GeneralMy vote of 5 Pin
Monjurul Habib13-Mar-12 10:49
professionalMonjurul Habib13-Mar-12 10:49 
GeneralMy vote of 5 Pin
ProEnggSoft7-Mar-12 15:19
ProEnggSoft7-Mar-12 15:19 
QuestionAnd reference it I will! Pin
Sander Rossel24-Feb-12 22:32
professionalSander Rossel24-Feb-12 22:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.