我有一个带有整数的或运算符(||),但由于某种原因它给了我一个错误。整数是位置。我想跟踪玩家的位置,这样我就可以在一大块代码中控制所有操作。看起来像的行if (location == (1 || 2 || 3)给了我错误。
Actions:
Console.WriteLine("");
Console.Write("What should i do? ");
string move = Console.ReadLine();
if (move.Contains("north"))
{
if (location == (1 || 2 || 3))
{
Console.WriteLine("There is a cliff here I cant climb up!");
}
}
else if (move.Contains("east"))
{
if (location == (3 || 6 || 9))
{
Console.WriteLine("There is a cliff here I cant climb up!");
}
}
else if (move.Contains("south"))
{
if (location == (7 || 8 || 9)) …Run Code Online (Sandbox Code Playgroud)