Click here to Skip to main content
15,908,841 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hai,

I am having some programs in java.I want to convert this into c# .net.How can I do this.Is there any link for this?
Posted

Try this ,it is just enough to convert the decaration,keywords, loops and syntax etc.
 
Share this answer
 
Comments
Raj.rcr 16-Mar-11 2:55am    
Good link.. my 5
There is no converter for java code to C#.Net since both use completely different frameworks. This means the classes and librarys they rely on are completely different thus not allowing an automated line by line conversion of the source code.
So, your only option is to do that manually line by line.
 
Share this answer
 
Comments
Tarun.K.S 16-Mar-11 2:25am    
Absolutely!
Sergey Alexandrovich Kryukov 16-Mar-11 2:26am    
Rewrite your software! Down the road you will clean it up. My 5.
It's amazing that such things happen: migration from Java to .NET.
--SA
Espen Harlinn 16-Mar-11 4:06am    
While some attempts have been made, by MS and others - I've never been happy with the results - my 5
import java.io.*;
import java.net.*;

public class Lookup
{
public static void main(String[] args) throws Exception
{
System.out.println("Hello World!");
String client = "api";
String apikey = "ABQIAAAAdGnGSqPru2GZ5ZCwFZsLDhQM9mDvw_EbadXXtLQ5SlzX_s0ijA";
String appver = "1.5.2";
String pver = "3.0";
String url = "http://www.yahoo.com";
String uri = "https://sb-ssl.google.com/safebrowsing/api/lookup?client="+client+"&apikey="+apikey+"&appver="+appver+"&pver="+pver;//+"&url="+url;

URL lookUrl = new URL(uri);
HttpURLConnection htCon = (HttpURLConnection) lookUrl.openConnection();
htCon.setDoInput(true);
htCon.setDoOutput(true);

//OutputStream os = htCon.getOutputStream();
PrintStream pos = new PrintStream(htCon.getOutputStream());
pos.println(2);
pos.println("http://www.asdrediff.com");
pos.println("http://www.yahooabds.com");
pos.close();

System.out.println("respose code:" + htCon.getResponseCode());
BufferedReader br = new BufferedReader(new InputStreamReader(htCon.getInputStream()));
String str = "";
while((str = br.readLine()) != null) {
System.out.println(str);
}
br.close();
htCon.disconnect();
System.out.println("end");
}
}
 
Share this answer
 
URL lookUrl = new URL(uri);
HttpURLConnection htCon = (HttpURLConnection) lookUrl.openConnection();
htCon.setDoInput(true);
htCon.setDoOutput(true);

//OutputStream os = htCon.getOutputStream();
PrintStream pos = new PrintStream(htCon.getOutputStream());
pos.println(2);
pos.println("http://www.asdrediff.com");
pos.println("http://www.yahooabds.com");
pos.close();

System.out.println("respose code:" + htCon.getResponseCode());
BufferedReader br = new BufferedReader(new InputStreamReader(htCon.getInputStream()));
String str = "";
while((str = br.readLine()) != null) {
System.out.println(str);
}
br.close();
htCon.disconnect();
System.out.println("end");
 
Share this answer
 
String connOption = config.getConfigParameter("ConnectionOption");
if(connOption.equalsIgnoreCase("pacaddress")){
return resolvePACAddress(config.getConfigParameter("PACAddress"));
}else if (connOption.equalsIgnoreCase("usefollproxy")) {
String server = config.getConfigParameter("ProxyServerName");
int port = Integer.parseInt(config.
getConfigParameter("ProxyServerPort"));
if(null != server && !server.equals("")){
List<proxy> proxyList = new ArrayList<proxy>();
Proxy proxy = new Proxy(Type.HTTP,
new InetSocketAddress(server, port));
proxyList.add(proxy);
return proxyList;

}else {
throw new DynaCredException("Invalid proxy details");
}
}else {
System.setProperty("java.net.useSystemProxies", "true");
List<proxy> l = null;
try {
l = ProxySelector.getDefault().select(new URI("http://www.google.com"));
}
catch (URISyntaxException e) {}
return l;
}
 
Share this answer
 
Comments
Manas Bhardwaj 17-Aug-12 5:55am    
Why (re)opening this old thread?

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900