就是按下“分析”按钮后,统计编辑框1的文字并在编辑框2输出:此段文字中有中文x个,英文x个,数字x个。

解决方案 »

  1.   

     string s = "abcd45612,asd";
                int characters = 0;
                int numbers = 0;
                int symbols = 0;
                foreach (char c in s)
                {
                    if ((c >= 33 && c <= 47) || (c >= 58 && c <= 64) || (c >= 91 && c <= 96) || (c >= 123 && c <= 126))
                        symbols++;
                    if ((c >= 65 && c <= 90) || (c >= 97 && c <= 122))
                        characters++;
                    if (c >= 48 && c <= 57)
                        numbers++;
                }