+ 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!
5 Antworten
+ 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
+ 6
You can visit
https://codeasy.net/lesson/bool_type_introduction
+ 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.
+ 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
0
Its a comparision like math