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();
Asked
Active
Viewed 46 times
-4

Kenneth K.
- 2,987
- 1
- 23
- 30

Ali Raza
- 1
-
8[What is a NullReferenceException, and how do I fix it?](//stackoverflow.com/q/4660142) – 001 Sep 19 '19 at 19:33
-
Welcome to stackoverflow... https://stackoverflow.com/help/how-to-ask – quaabaam Sep 19 '19 at 19:35
-
Please provide a [MVCE](https://stackoverflow.com/help/minimal-reproducible-example) in your question. As posted, there is no obvious NRE. – Kenneth K. Sep 19 '19 at 19:49
1 Answers
-1
If you're taking inputs as this
Console.WriteLine("Press 1 for PackMan 2 Ghost and 3 for AC FSM");
Then
You should try using switch case it will work
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
}
}
}

Chris Dunaway
- 10,974
- 4
- 36
- 48

Prathm
- 1
- 1
-
When posting code, please format it appropriately so it is easy to read. Also, make sure it compiles. Your code as listed does not compile. – Chris Dunaway Sep 19 '19 at 20:21