Is there a way to toggle a boolean variable in C#?

Yes. Use the following:

locked = !locked;

Leave a Comment