C# .NET - how to convert the following code to c#

Asked By abinav shankar on 31-Oct-11 12:29 AM
hi i want to convert the following java code to c#

HttpPost httpPost = new HttpPost("http://www.inspire-geoportal.eu/INSPIREValidatorService/resources/validation/inspire");
//xml response: httpPost.addHeader("Accept", "application/xml");
//html response
httpPost.addHeader("Accept", "text/html");
FileBody dataFile = new FileBody(new File("yourMetadataFile.xml"));
MultipartEntity reqEntity = new MultipartEntity();
reqEntity.addPart("dataFile", dataFile);
HttpResponse response = httpclient.execute(httpPost);
int statusCode = response.getStatusLine().getStatusCode();
switch (statusCode) {
    case 200:   //implement the below method to extract the response
    //Exception was thrown
    case 400:   //implement the below method to handle the exceptions
    //Internal error from the service
    default:    //implement the below method to handle errors such as internal server error
smr replied to abinav shankar on 31-Oct-11 12:34 AM

The Java Language Conversion Assistant (JLCA) is a tool that provides the ability to convert Java code and library http://www.developer.com/net/csharp/article.php/2235411/Converting-Java-to-C.htm# to Microsoft Visual C# .NET. Built based on the ArtinSoft migration technology, this second version adds a number of additional features to its abilities. This includes the ability to convert code from both the client and the server. Developers will be able to convert Web as well as Windows®-based applications. Java Server Pages and Java servlets can also be converted to ASP.NET.

follow these links
Venkat K replied to abinav shankar on 31-Oct-11 12:53 AM
Microsoft's product to help migrate Java apps to .NET is JUMP:


Translating Java code to C# code is not especially difficult, provided
you have a managed library which implements all the Java API calls you
use; then simply translating the syntax suffices, with special
provisions for some features found in Java but not C#. Octopus, one of
the best commercial translation products, does something like this:


However, translating Java in this manner yields, essentially, a Java
program written in C#, which frankly hardly seems worthwhile.
Translating Java code to idiomatic, typical C# code is a much more
difficult process, because a real C# program would use .NET library
calls, which, as Nicholas explained, have no useful general mapping to
Java API calls, and also has a number of stylistic and algorithmic
differences that are difficult or even unfeasible to map.

Rather than translate Java to C#, a better approach may be to
use a tool such as IKVM to allow your Java classes to be accessed
directly from other C# code through the .NET Framework:


Reena Jain replied to abinav shankar on 31-Oct-11 01:06 AM

Microsoft Visual Studio 2005 provides the ability to convert projects created in Visual J++® version 6.0 or written in the Java language to Visual C#® so that you can take advantage of the .NET Framework. Java Language Conversion Assistant generates a new Visual C# project from an existing Visual J++ 6.0 project or Java-language files. The Java Language Conversion Assistant wizard makes it easy to convert your existing files.

dipa ahuja replied to abinav shankar on 31-Oct-11 01:10 AM
Download from here :

Devil Scorpio replied to abinav shankar on 31-Oct-11 01:30 AM
  • http://en.wikipedia.org/wiki/J_Sharp is Microsoft's Java language implementation on .NET. You can access Java libraries (up to version 1.4, anyways).

  • http://www.mono-project.com/Java also runs Java on the CLR, with access to other .NET programs.

  • Microsoft Visual Studio 2005 comes with a "Java language conversion assistant" that converts Java programs to C# programs automatically for you.