<分区>
这是我遇到问题的代码,我正在尝试检索错误猜测次数 ( numbWrong ) 的值。怎么查不到猜错的次数?
...
{
Console.WriteLine("Enter your guess letter using lowercase only.");
char input = Console.ReadLine().ToCharArray()[0];
for (int i = 0; i < myWord.Length; i++)
{
//if the user guessed right, replace the correct dash and display to the user
if (myWord[i] == input)
{
count++; //update the count
a[i] = input; //if guess is correct, dash is replaced by what the user used as input
//show the new dash array mixed with correct guesses
for (int j = 0; j < a.Length; j++)
{
Console.Write(a[j] + " ");
}
else
{
numbWrong += 1;
}
}
Console.WriteLine();
Console.WriteLine("You guessed it right after ");
Console.Write(numbWrong);
Console.Write(" incorrect guesses.");
}
错误:
"Use of unassigned local variable 'numbWrong' "