gpt4 book ai didi

c# - 你如何检索变量?

转载 作者:太空宇宙 更新时间:2023-11-03 19:01:28 24 4
gpt4 key购买 nike

<分区>

这是我遇到问题的代码,我正在尝试检索错误猜测次数 ( 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' "

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com