Hello, I’m working on this task:
Write a program that reads an integer count, for the number of characters to read, from the console. Then, from a new line, the program should read count characters written in one line from the console. Finally, the program should output only the letters from the characters to the console on one line. For example:
>10
>FL45H0b12c
FLHbc
Here is my code:
namespace CharType
{
class OnlyLetters
{
static void Main(string[] args)
{
int count = int.Parse(Console.ReadLine());
string sum = "";
for (int i = 0; i < count; i++)
{
char c = char.Parse(Console.ReadLine());
Console.Write(c);
if (char.IsLetter(c))
{
sum = sum + c;
}
}
Console.Write(sum);
}
}
}
Can anyone please help me to solve it?
Can not find how to read characters from the same line.
My program outputs:
10
a
az
zx
xc
cg
g5
56
6F
Fx
xa
aazxcgFxa