I searched this site for similar questions and the ones I found do not work for me. I apologize for asking if there is an answer somewhere, and I could not find it. Please let me know if I am doing something wrong by asking about it.
I am doing an executioner in C #. I made the program select a random string from the array, create an array of guessed letters (which it initially fills "_" until that word). Then he should get user input for the letter, see if this letter is in the word, and if so, add this letter to the array of guessed letters. I am stuck in 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; } } }
In " if (gameWord[x] == guessedLetter) " I get the error message indicated in the header.
gameWord is a string selected from an array of strings, and guessedLetter is a string entered by the user using Console.ReadLine(); .
source share