无法让切换功能工作以进入不同的静态 class

Can't get switch function to work to get into a different static class

我对 C# 和整体编程还很陌生。我现在正在做家庭作业,我正在失去理智,因为我无法理解我的错误是什么。我觉得它一定是很明显的东西,但我就是看不到它。错误是 "ProgramBase.Menu()", "The name 'Console'does not exist in the current context", "QuestionRectangle 在当前上下文中不存在".

using System;

namespace ProgLab3
{
class Program
{
    static void Main(string[] args)
    {
        bool displayMenu = true;
        while (displayMenu)
        {
            displayMenu = Menu();
        }
    }

    private static bool Menu()
    {


        Console.Clear();
        Console.WriteLine("Welcome to the menu! Below are your choices of options.");
        Console.WriteLine("Type 1 to open Areas of Rectangles\n");
        Console.WriteLine("Type 2 to open Biggest Number\n");
        Console.WriteLine("Type 3 to open Valid Points\n");
        Console.WriteLine("Type 4 to open Dollar Game\n");
        Console.WriteLine("Type 5 to open Oldest Person\n");
        Console.WriteLine("Type 6 to open Hi Lo Game\n");
        Console.WriteLine("Type 7 to quit\n");

        switch (Console.ReadLine())
        {
            case "1":
                QuestionRectangle();
                return true;
            case "2":

                return true;
            case "3":
                return false;
            default:
                return true;
        }
    }


    private static void QuestionRectangle()
    {
        {
            double width1, length1, area1;
            double width2, length2, area2;

            // Asking the user for measurements and then saving those numbers onto variables for the FIRST rectangle
            Console.WriteLine("Welcome to the Areas of Rectangles choice.\nPlease start off by inputting the width of your first rectangle, do not include the metric unit of measurement.");
            width1 = Convert.ToDouble(Console.ReadLine());
            Console.WriteLine("Now please input the length of the first rectangle.");
            length1 = Convert.ToDouble(Console.ReadLine());
            //Calculating the area of the FIRST rectangle
            area1 = width1 * length1;

            // Asking the user for measurements and then saving those numbers onto variables for the SECOND rectangle
            Console.WriteLine("Alright great, now please input the width of your second rectangle.");
            width2 = Convert.ToDouble(Console.ReadLine());
            Console.WriteLine("Now what is the length of your second rectangle?");
            length2 = Convert.ToDouble(Console.ReadLine());
            //Calculating the area of the SECOND rectangle
            area2 = width2 * length2;

            // Checks if area 1 is greater than area 2
            if (area1 > area2)
            {
                Console.WriteLine("Your first rectangle has a greater area, that area being " + area1);
            }

            // Checks if area 2 is greater than area 1
            if (area1 < area2)
            {
                Console.WriteLine("Your second rectangle has a greater area, that area being " + area2);
            }

            // Checks if the areas are equal to each other
            if (area1 == area2)
            {
                Console.WriteLine("Your rectangles have the same area, that area being " + area1);
            }
        }
    }
}

}

错误告诉您 Console/QuestionRectangle 在当前上下文中无法访问。这可能意味着以下一项或多项:

  • 你打错了
  • 资源未在当前命名空间中定义
  • 该资源存在于另一个命名空间中,该命名空间未使用 using 关键字包含

因此,您将需要检查您的命名空间并相应地解决您遇到的问题。我可以看到 QuestionRectangle 在您的代码中定义,所以我想您的实际代码可能不同,或者在未共享的地方有问题。

编辑

事实证明,在这种特殊情况下,复制的内容在途中被破坏了。 carsonSgit 调查了这个问题并能够定位缺失的内容。从那时起,通过确保源和目标相同,him/her 更容易找到解决方案的路径。