Is there a simple way to use a bool like a radio button

I want to write a piece of code that makes sure only one bool at a time could be true.

For example:

IsWalking == true;

IsSitting = false;
IsStandingStill = false;
IsDoingAnythingElseReally= false;

Of course if IsStandingStill where to become true, the rest would go false. Can anyone help me out here?

UPDATE:

Thank you guys, I managed to get enums to work and do the job!

Have a look at enumerations (enum).

4 Likes

Make them all private, then make properties for all of them and in the setter put the rest false if put true. But if you’re going to have more than let’s say three or four (and don’t yet know if there will be more) I would go with an enum.

1 Like

Thank you guys, I’m going to go learn about enums