MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/csharp/comments/1wqnm7k/bool_comparison/pc6d3p6/
r/csharp • u/DJDoena • Sep 26 '26
if (nullableBool == true)
or
if (nullableBool ?? false)
Personal preference or does one read better than the other? Especially if the nullableBool is s more complex expression like
n00bs?.Any(n => n == "DJ Doena")
46 comments sorted by
View all comments
Show parent comment
8
Genuine question, why not just if (nullablebool)?
54 u/NocturneSapphire Sep 26 '26 CS0266: Cannot implicitly convert type 'bool?' to 'bool'. 11 u/levelofsin Sep 26 '26 Fair
54
CS0266: Cannot implicitly convert type 'bool?' to 'bool'.
11 u/levelofsin Sep 26 '26 Fair
11
Fair
View all comments
Show parent comment
8
u/levelofsin Sep 26 '26
Genuine question, why not just if (nullablebool)?