Question: c# question I'm trying to use Keypress in a game program with a switch statement. When a user press ConsoleKey.A: something happens// ConsoleKey.B: //something happens...

c# question

I'm trying to use Keypress in a game program with a switch statement.

When a user press ConsoleKey.A: something happens//

ConsoleKey.B: //something happens...

How can disable and enable a function with the same key? for example, if the user press Z some function gets activated, if the user press Z again that function is disabled I was trying to do something like this but it doesn't seem to work:

case ConsoleKey.Z: { if (activate != true) { activate = true; Console.WriteLine("ACTIVE.."); break; } else { activate = false; Console.WriteLine("Deactivating."); break; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!