有没有办法使用if语句来检查整数是否等于另一个整数?下面的代码给出了一个错误,说|| OR运算符不能用于int和int类型.是否有更好的方法来解决这个问题,而不是将每个选项作为单独的IF语句?
if (role = 7 || 11)
{
Console.WriteLine("You won!");
}
if (role = 2 || 3 || 12)
{
Console.WriteLine("You lost.");
}
Run Code Online (Sandbox Code Playgroud)