Question: I was wondering what was the most clean and understandable syntax for doing condition checks on nullable bools. 

Is the following good or bad coding style? Is there a way to express the condition better/more cleanly?

```
bool? nullableBool = true;
if (nullableBool ?? false) { ... }
else { ... }

```

especially the **if (nullableBool ?? false)** part. I don't like the `if (x.HasValue && x.Value)` style ...

*(not sure whether the question has been asked before ... couldn't find something similar with the search)*

Answer: 
Use extensions.

```
public static class NullableMixin {
    public static bool IsTrue(this System.Nullable<bool> val) {
        return val == true;
    }
    public static bool IsFalse(this System.Nullable<bool> val) {
        return val == false;
    }
    public static bool IsNull(this System.Nullable<bool> val) {
        return val == null;
    }
    public static bool IsNotNull(this System.Nullable<bool> val) {
        return val.HasValue;
    }
}

Nullable<bool> value = null;
if(value.IsTrue()) {
// do something with it
}

```
Given enum

```
public enum PublishMode { Edit, View }

```

you can do it like here

```
 void MyMethod(PublishMode? mode)
    {
       var publishMode = mode ?? PublishMode.Edit;

//or
       if (mode?? PublishMode.Edit == someValue)
       ....
    }

```