저는 현재 간단한 주사위 게임을 코딩하고 있으며 혼란스럽고 혼란스러운 오류가 발생했습니다. 암호.CS0019 t 연산자 '+ ='는 'int'및 'bool'타입의 피연산자에 적용 할 수 없습니다.
foreach (var die in Dice.rolls)
{
Console.WriteLine(die.ToString());
}
if (player.score += score >= goal)
{
playing = false;
Console.WriteLine("{0} has won the game!", player.name);
Console.WriteLine("Please press any key to end the game");
Console.ReadKey();
}
else
{
player.score += score;
}
난 데 문제는 라인이 : 말해 오류를 던지고있다
if (player.score += score >= goal)
내가있는 if 문에서 INT 년대와 부울의하지만 모든 변수에 사용할 수 없습니다 int 's. 또한 여기 몇 줄 :
player.score += score;
어떤 오류가 있습니까? 아니요.
자세한 정보를 찾아 볼 수 있습니다. 먼저 점수를 더한 다음 비교를하십시오. 컴파일러에게 말하는 것은 score> = goal을 해결하고이를 player.score에 추가하는 것입니다. 따라서 오류가 발생합니다. –