日期:2014-05-17 浏览次数:20754 次
1. 来张 效果图 (简陋的界面 凑合着看吧)
2. 代码
private void button1_Click(object sender, EventArgs e) { string sin = txtsid.Text; int alpha = 0; int num = 0; int spc = 0; for (int i = 0; i < sin.Length; i++) { string ch = sin.Substring(i, 1); if (ch == " ") spc += 1; else if (char.IsNumber(ch, 0)) { num += 1; } else if (char.IsUpper(ch, 0) | char.IsLower(ch, 0)) { alpha += 1; } } MessageBox.Show("空格=" + spc + ",数字=" + num + ",字母=" + alpha); }