Hello, I’m working on this task:
Write a program that reads a string and an integer number N from the console. It should then output the string’s _N_th character to the console. For example:
>Make deals with machines
>4
e
Here is my code:
namespace CharType
{
class OutputCharacterNumber
{
static void Main(string[] args)
{
string sentens = Console.ReadLine();
char sent = char.Parse(sentens);
int number = int.Parse(Console.ReadLine());
char need = sent[number - 1];
Console.WriteLine(need);
}
}
}
Can anyone please help me to solve it?