+ 4

how do booleans work? c#

i don’t really understand how they work and how i should use them, can u give me an example? thank you so much!

21st Mar 2019, 3:10 AM
Julia GarcĂ­a
Julia GarcĂ­a - avatar
5 Answers
+ 8
‱ Bool is often used in expressions. Many expressions evaluate to a boolean value. Represented in one byte, the bool type represents truth. For example: A bool can be assigned to the 'true' and 'false' literals. We set the bool variable to 'true'. And then we invert the value of the bool using the exclamation operator. bool val = true; if (val) { Console.WriteLine(val == true); } val = !val; if (!val) { Console.WriteLine(val == false); } Output: True True
21st Mar 2019, 11:15 AM
Danijel Ivanović
Danijel Ivanović - avatar
21st Mar 2019, 9:35 AM
VEDANG
VEDANG - avatar
+ 1
boolean is a logical operator. its can store a logical value. for example component is visible? true/false. is x>y? true/false. you can used it in conditions. its cheap for memory storage. because boolean need to reserve just 1 bit. logical 1 or logical 0. with this you can use logical operator and or xor. its very usefull thing.
21st Mar 2019, 9:40 PM
Pavel Ć estĂĄk
Pavel Ć estĂĄk - avatar
+ 1
Boolean is are logical operator for comparing stating a logic if a certain condition Try taking a look at few this mathematics topic Boolean Algebra
23rd Mar 2019, 1:06 AM
George S Mulbah II
George S Mulbah II - avatar
0
Its a comparision like math
3rd Apr 2019, 5:05 AM
Tony Stark
Tony Stark - avatar