I am trying to make a simple program in C# code (Console Application), which prompts the user to enter 10 names and then the 10 names displayed at the end in a random order (not the order the names were entered in)
This is how far I have gotten:-
static void Main(string[] args)
{
string[] names = new string [10];
int i;
for ( i = 0; i < 10 ; i++)
{
Console.WriteLine("Give me name " + (i+1) );
names[i] = Console.ReadLine();
}
for (int j = 0; j <= 10; j++)
{
Console.WriteLine(names[j]);
}
Console.ReadLine();
}
So far I have been able to prompt the user for 10 names, and store those 10 names, and display them at the end, however, once they are displayed I get the error :- "IndexOutOfRangeException was unhandled" and the Console.WriteLine(names[j]);
gets highlighted.
Lastly, once these problems are sorted, how do I display the names entered back in random order?
Thanks for reading.