代码人生的小狗窝

一行行枯燥的代码,却描绘出人生的点点滴滴

您现在的位置是:首页>_C#

刚开始接触c#遇到的小疑点,跪求高手解决

发布时间:2019-08-17浏览(1846)

    刚开始接触c#遇到的小问题,跪求高手解决.
    using   System;
    using   System.Collections;
    using   System.ComponentModel;
    using   System.Data;
    using   System.Net   ;
    using   System.IO   ;
    using   System.Text   ;
    using   System.Text.RegularExpressions;
    using   System.Web   ;

    namespace   WindowsApplication5
    {
    public   class   Post
    {
    public   static   void   Main(string   []   args)
    {
    Post   zhucheng=new   Post();
    zhucheng.zhuchengxu();

    }
    public   void   zhuchengxu()
    {
    try
    {
    ASCIIEncoding   encoding=new   ASCIIEncoding();
    string   postData= "COMMANDID=05 ";
    byte[]     data   =   encoding.GetBytes(postData);
    //   Prepare   web   request
    HttpWebRequest   myRequest   =(HttpWebRequest)WebRequest.Create( "http://61.156.3.58/test.jsp ");
    myRequest.Method   =   "POST ";
    myRequest.ContentType= "application/x-www-form-urlencoded ";
    myRequest.ContentLength   =   data.Length;
    Stream   newStream=myRequest.GetRequestStream();
    //   Send   the   data.
    newStream.Write(data,0,data.Length);
    newStream.Close();
    HttpWebResponse   webResponse   =   (HttpWebResponse)   webRequest.GetResponse();
    Stream   stream=webResponse.GetResponseStream();
    System.IO.StreamReader   streamReader   =   new   StreamReader(stream,   System.Text.Encoding.GetEncoding( "GB2312 "));
    string   content   =   streamReader.ReadToEnd();
    //   关闭相关对象
    streamReader.Close();
    webResponse.Close();
    }

    catch(Exception   ed   )  
    {  
    Console.WriteLine   (   "发生 "   +   ed.ToString()+ "错误! "   )   ;  
    }
    }
    }
    }
    程序总出错误


    ------解决方案--------------------
    我就没有装过VS2003对我来说太大了...

    我就是用命令行

    把你的代码复制到 test2.cs

    然后
    csc test.cs

    就提示上面的错误了....