C# – Explicitly compare bool? with true/false to avoid compile-time errors and runtime exceptions

You can’t use nullable bools (bool?) exactly like regular bools, because they aren’t the same thing. When you try to use them like regular bools, you run into compiler errors and runtime exceptions. Fortunately, there is a simple, concise way to treat nullable bools almost-like regular bools. You have to explicitly compare them with true/false. … Read more C# – Explicitly compare bool? with true/false to avoid compile-time errors and runtime exceptions