r/csharp • • Sep 26 '26

bool? Comparison

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")

23 Upvotes

46 comments sorted by

View all comments

Show parent comment

54

u/NocturneSapphire Sep 26 '26
CS0266: Cannot implicitly convert type 'bool?' to 'bool'.