+ 1

I don't understand booleans...can anyone explain me this plzz

plz explain briefly i dont get what are booleans i just know they are true&false

6th Sep 2018, 5:30 PM
Darpan Kushwaha
Darpan Kushwaha - avatar
4 Réponses
+ 2
Darpan Kushwaha consider a case that you are trying to access some file content... if you get that file content, you are suppose to do further task otherwise not.. in this scenario, you can declare bool as true to indicate that all cases will be passed... in between while trying to access content, if anything goes wrong, you set it as false...at end, you simply write that do next steps only if bool has value as true... feel free to ask for doubt...
6th Sep 2018, 6:13 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 1
plz can u get me some examples
6th Sep 2018, 6:18 PM
Darpan Kushwaha
Darpan Kushwaha - avatar
+ 1
Bool is a handy variable type when you know, there are only 2 options. For example Person.HasDriverLicence A Person object, can have a property "HasDriverLicense". This is either true or false. For a method bool ReadFromDataBase if ReadFromDataBase was succesfull the method can return true. If an error occurred ReadFromDataBase can return false. Now ReadFromDataBase can be used in a if-statement if (ReadFormDatabase) { //do something with the read data } else { //show error occurred }
6th Sep 2018, 8:42 PM
sneeze
sneeze - avatar
0
1 == True 0 == False booleans == True / False
6th Sep 2018, 6:46 PM
Sousou
Sousou - avatar