如何判断输入的字符是否含数字

private void textBox1_TextChanged(object sender, EventArgs e) 
{ 
char[] ch = textBox1.Text.ToCharArray(); 
bool IsChinese = true; 
int ch_start = Convert.ToInt32("4e00", 16); 
int ch_end = Convert.ToInt32("9fff", 16); 

foreach ( char c in ch) 
{ 

if (Convert.ToInt32(c) < ch_start | Convert.ToInt32(c) > ch_end) 
{ 
IsChinese = false; 
break; 
} 
} 
if (IsChinese == false) 
{ 
MessageBox.Show("您输入了非中文字符","提示"); 
} 
}

 

posted @ 2012-07-06 14:58  O.Sheet  阅读(169)  评论(0编辑  收藏  举报