当前位置:编程学习 > JAVA >>

将一段Java代码转换为C#···求高人指点··

如下·
Java中的一小段代码··
想转为C#··但是不知道怎么办···

private static void encodeAndPost(String id,String ud)throws Exception{

  String k= "__ap=";

  String v="{\"videoId\":\""+id+"\",\"type\":\""+ud+"\"}";

  v=URLEncoder.encode(v,"UTF8");

  doPost(k+v);}

 private static void doPost(String pms)throws Exception{
 String url="......................";
  URL u = new URL(url);

  HttpURLConnection connection=(HttpURLConnection)u.openConnection();

  connection.setRequestMethod("POST");

  connection.setRequestProperty("Content-Type","application/x-www-form-urlencoded");

  connection.setRequestProperty("Content-Length",String.valueOf(pms.length()));

  connection.setUseCaches(false);

  connection.setDoOutput(true);

  DataOutputStream dout=new DataOutputStream(connection.getOutputStream());

  dout.write(pms.getBytes());

  dout.flush();

  dout.close();

  connection.getInputStream().close();

  connection.disconnect(); --------------------编程问答-------------------- 其实只有一点点··关键字的更改···
不知道在 C#里如何表示··
补充:Java ,  Java EE
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,