I have searched this site for similar questions and the ones I've found don't work for me. I apologize for asking if the answer is somewhere and I haven't been able to find it. Please let me know if I am doing something wrong by asking this.
I am making hangman in C#. What I've done is make it so that the program picks a random string from an array, makes an array of the guessed letters (which it initially fills with '_' for as long as the word is). It then is supposed to get a user's input for a letter, see if that letter is in the word, and if it is, add that letter to the guessed letters array. I am stuck at this part:
if (gameWord.Contains(guessedLetter))
{
//for every character in gameWord
for (int x = 0; x < gameWord.Length; x++)
{
//if the character at the 'x' position in gameWord is equal to the guessed letter
if (gameWord[x] == guessedLetter)
{
//guessString at that x position is equal to the guessed letter
guessString[x] = guessedLetter;
}
}
}
At "if (gameWord[x] == guessedLetter)
" I am getting the error shown in the title.
gameWord is a string chosen from an array of strings, and guessedLetter is a string inputted by the user with Console.ReadLine();
.