This maybe sound strange to you but I'm too lazy to write everytime like
if (threadAlive) { threadAlive = false; } else { threadAlive = true; }
isn't there is something like int++ or int-- to change bool value to opposite of its value?
Invert a boolean method or propertyRight-click and choose Refactor | Invert Boolean from the context menu. Choose ReSharper | Refactor | Invert Boolean… from the main menu.
The operator. not_() function takes a boolean value as its argument and returns the opposite of that value.
To declare a Boolean variable, we use the keyword bool. To initialize or assign a true or false value to a Boolean variable, we use the keywords true and false. Boolean values are not actually stored in Boolean variables as the words “true” or “false”.
C# has two different categories of types: value types and reference types. Amongst other, more important distinctions, value types, such as bool or int, cannot contain null values.
Just do this:
threadAlive = !threadAlive;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With