刚开始接触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
就提示上面的错误了....