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 sentence = Console.ReadLine();
int N = int.Parse(Console.ReadLine());
Console.WriteLine(sentence[N]);
}
}
}
Can anyone please help me to solve it?
Works fine with any other text, but somehow “Make deals with machines” doesn’t output anything as it is counting from 0 unlike the task which starts from 1. Is this seriously not my fault?