Please help me with the task: "Only letters output"

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:

Here is my code:

namespace CharType
   class OnlyLetters
       static void Main(string[] args)
           int a = int.Parse(Console.ReadLine());
           string c = "";
           for (int i = 0; i < a; i++)
               char b = Convert.ToChar(Console.Read());
               c = c + b;

ok right now I’m focusing on writing the code for reading the n number of char, so
why this code isn’t repeat (i < a) time…

1 Like

Hi siddharth1, welcome to Codeasy!

I think you forgot to include

using System;

at the top of the file. Please let me know if it worked after you added it.

it was there in visual studio… i thing i forgot to copy that… but rest of the code is same.
problem is that the code is working if i use string instead of char …i just want the know the logic why this code isnt working with char thanks…

I’m not sure what you mean by ‘string instead of char’. Can you please show an example so that I understand what code versions do you compare?