有没有办法这一句MessageBox.Show(Http.numble);放到主函数中去,并且不去改变方法Get_Check()的类型
部分代码如下:
这是封装好的一个类里面的方法 (这里面的 Http.Get是从网页上获取数据的一个方法)
unsafe public static bool Get_Check(string url, Dictionary<string, string> UseFor)
{
Http.rel = Http.Get(url, UseFor);
Http.numble = Http.rel.Substring(73, Http.rel.Length - 82);//从获取的文本数据中摘出自己想要的,通过了就会有PASS,没有通过就会有NG;
if (Http.numble.Contains("NG") == true)
{
n = false;
MessageBox.Show(Http.numble);
}
else
n = true;
return n ;
}
这是主程序的调用这个方法
private unsafe void Button2_Click(object sender, EventArgs e)
{
string url1 = "http://10.11.2.8:86/NPI.asmx/Sync_CheckStation";
Dictionary<string, string> UseFor = new Dictionary<string, string> {
{"sn",textBox1.Text},{"station",textBox2.Text},{"type","BZ"}
};
if(Http.Get_Check(url1, UseFor)==true)
{
MessageBox.Show("PASS");
}
}