首页 运维 网络学院 查看内容

C# 判断网络是否通的代码

2013-5-14 11:21 1151 0

摘要:   2012-02-07 22:18        by      &...
关键词: nbsp MessageBox pattern Show InternetGetConne privatevoid ctedState Connected EventArgs address

  2012-02-07 22:18        by         通用信息化建设平台,         1021         阅读,         3         评论,         收藏,         编辑  [DllImport("wininet.dll")]  privateexternstaticbool InternetGetConnectedState(outint conn, int val);  public Form1()  {  InitializeComponent();  }  privatevoid button1_Click(object sender, EventArgs e)  {  int Out;  if (InternetGetConnectedState(out Out, 0) == true)  {  MessageBox.Show("Connected !");  }  else  {  MessageBox.Show("Not Connected !");  }  }  判断邮箱地址是否有效的参考代码  privatevoid button1_Click(object sender, EventArgs e)  {  string pattern = null;  pattern = "^([0-9a-zA-Z]([-\\.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})$";  if (Regex.IsMatch("[email protected]", pattern))  {  MessageBox.Show ("Valid Email address ");  }  else  {  MessageBox.Show("Not a valid Email address ");  }  }
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系 [邮箱地址] 删除

路过

雷人

握手

鲜花

鸡蛋

最新评论

返回顶部