string Input = "";
string[] Words = { "elephant", "lion" };
string[] Clues = { "Has trunk?", "Is gray?", "Is yellow?", "Has mane?"};
.........
Console.WriteLine("Do you want to add you own animal? y/n ? \n");
Input = Console.ReadLine();
if (Input == "Y" || Input == "y")
{
Console.WriteLine("Enter an animal name: \n");
//Array.Resize(ref Words, Words.Length + 1);
Input = Console.ReadLine();
Words[Words.Length] = Input;
Console.WriteLine("Enter 2 clues \n");
for (int i = 1; i <=2 ; i++)
{
Console.WriteLine("Clue" + i + ":");
Clues[Clues.Length] = Console.ReadLine();
}
}
This is the standard guess the animal game..
I am getting an index out of bounds at line Words[Words.Length] = Input;.. the new animal and clues entered also needs to be available the next time i play the game..
List<string>(andVariableName.Add) rather than an array.for (int i = 1; i <=2 ; i++)should befor (int i = 0; i < 2 ; i++).