我如何解决此问题“系统空引用错误”

时间:2019-09-19 19:30:23

标签: c#

static void Main(string[] args)
{
    Program obj = new Program();
    Console.WriteLine("Press 1 for PackMan 2 Ghost and 3 for AC FSM");
    string input = Console.ReadLine();

    //if (input == "1")
    //{
    obj.Packman();

1 个答案:

答案 0 :(得分:-1)

如果您要这样输入

Console.WriteLine(“按1表示PackMan 2 Ghost,按3表示AC FSM”)

然后

您应该尝试使用开关盒,它会起作用

static void Main(string[] args) 
{ 
    Program obj = new Program();

    Console.WriteLine("Press 1 for PackMan 2 Ghost and 3 for AC FSM");
    string input = Console.ReadLine();

    Boolean exit= false;

    While(!exit){
        Switch (input)
        {
            case 1 :
                obj.Packman();
                break;
            case 2: 
                break;
            case 3: 
                break;
            case 4:
                Exit= true
        }
    }
}