I'm trying to do an assignment for my coding class and I'm quite new to this. My class wants someone to input 5 values into an array from user input. The statements MUST be in a while loop.
Here's my code
static void Main(string[] args)
{
string[] numbers = new string[6];
int i = 1;
while (i <= 5)
{
Console.Write("Please enter a number here:");
numbers[i] = Convert.ToInt32(Console.ReadLine());
i++;
}
}
}
}
The error occurs at
numbers[i] = Convert.ToInt32(Console.ReadLine());
I'm trying to convert the user input into an int value, but It doesn't let me. Any reason why? please let me know and understand I'm really new to this.