Namespace ConsoleApplication2
{
Class Program
{//letter Letter Gigit digit Symbol
static void Main (string[] args)
{
Console.WriteLine ("Please enter character");
string s = Console.ReadLine ();//input string is received with S
int letter = 0;//The initial number of letters is 0
int gigit = 0; The number of first digits is 0
int symbol = 0;//The number of first characters is 0
foreach (char c in s)
The {//foreach statement is used to iterate through the collection to get the information you want, syntax foreach (element type C int Traversal object s)
if (char. Isletter (c)) letter++;//extract the letters from the string
else if (char. IsDigit (c)) gigit++;//extracts a number from a string
else symbol++;//extracting symbols from a string
}
Console.WriteLine ("Number of letters:" + letter + "\ T" + "number:" + gigit + "\ T" + "number of characters:" + symbol);//Output
Console.ReadLine ();
}
}
}
foreach-(iterates through the characters in an array or loop for information)