小编Qua*_*dro的帖子

CS0019 C# 运算符 '||' 不能应用于“int”和“int”类型的操作数

我有一个带有整数的或运算符(||),但由于某种原因它给了我一个错误。整数是位置。我想跟踪玩家的位置,这样我就可以在一大块代码中控制所有操作。看起来像的行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)

c# operators

-2
推荐指数
1
解决办法
1399
查看次数

标签 统计

c# ×1

operators ×1