日期:2014-05-17  浏览次数:20850 次

在winform中,如何在textbox检查有多少个大写字母
在winform中,如何在textbox检查有多少个大写字母,恕我新手!!!求解!!!????
winform textbox

------解决方案--------------------
  int count = Regex.Matches(textBox1.Text, "[A-Z]").Count;
            MessageBox.Show("有" + count + "个大写字母");

------解决方案--------------------
private int i = 0;
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
//大写字母A-Z的ASC码范围是65-90;
if ((int)e.KeyChar > 65 & (int)e.KeyChar < 90 
------解决方案--------------------
 (int)e.KeyChar == 8)
{
i++;
}
MessageBox.Show(i.ToString());
}

------解决方案--------------------
int n = textBox1.Text.Where(x => x >= 'A' && x <= 'Z').Count();