日期:2014-05-17 浏览次数:21113 次
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++; } Console.WriteLine("共有{0}个字母,{1}个数字,{2}个标点", characters, numbers, symbols);