如果输入的不是英文字母或者数字或者汉字,则返回false

 public partial class Form1 : Form 

  •     { 
  •         public Form1() 
  •         { 
  •             InitializeComponent(); 
  •         } 
  •  
  •         private void button1_Click(object sender, EventArgs e) 
  •         { 
  •             string input = textBox1.Text.Trim(); 
  •             if (chkInput(input)) 
  •                 MessageBox.Show("true"); 
  •             else 
  •                 MessageBox.Show("false"); 
  •         } 
  •  
  •         /// <summary> 
  •         /// 如果输入的不是英文字母或者数字或者汉字,则返回false 
  •         /// </summary> 
  •         /// <returns></returns> 
  •         private bool chkInput(string input) 
  •         { 
  •             Regex regex = new Regex(@"^[u4E00-u9FFFA-Za-z0-9]+$"); 
  •             return regex.IsMatch(input); 
  •         } 
  •     } 
原文地址:https://www.cnblogs.com/DTWolf/p/4660802.html