using System; namespace huangyibiao { class Program { static void Main(string[] args) { int iCountLetters = 0; //number of letters int iCountDigits = 0; //number of digits int iCountPunctuations = 0; //number of punctuations Console.Write("Please enter a string to count: "); string strInput = Console.ReadLine(); foreach (var chr in strInput) { if (char.IsLetter(chr)) { iCountLetters++; } else if (char.IsDigit(chr)) { iCountDigits++; } else if (char.IsPunctuation(chr)) { iCountPunctuations++; } } Console.WriteLine("There {0} letters, {1} digits and {2} punctuations.", iCountLetters, iCountDigits, iCountPunctuations); } } }