C#C
C#3y ago
RobinTTY

❔ Nullable bools

I just got into the situation where I needed to use nullable bools and I'm a little confused about how the compiler handles things. If I write my code like shown in picture 1 the compiler still thinks the variable
accessScopesSupported
might be null inside the codeblock with an explicit check for null. If I use
.Value
inside the codeblock the compiler understands that the value cannot be null. My question is why? Shouldn't the null check be enough?
image.png
Screenshot_2023-05-24_190811.png
Was this page helpful?