How to simplify usage of nullable booleans in C#
Here is some example code to get started:

    class Foo
    {
       public bool? IsValid { get; set; }
    }
    
    // later in some other function...
    void DoStuff( Foo myFoo )
    {
       myControlState.Visible = myFoo.IsValid.HasValue ? myFoo.IsValid.Value : false;
    }

I run into a lot of situations where I have to use a ternary operator like above to properly use a nullable bool. It would be nice if there was a slightly simpler way of getting the value of the bool without throwing exceptions. The code above seems straight-forward but there are much more complex situations where this ends up being a lot of code. I was hoping for something simple like:

    myControlState.Visible = GetNullableValue<bool>( myFoo );

Does anyone have any cleaner alternatives to the ternary operator?
How to simplify usage of nullable booleans in C#
===

Here is some example code to get started:

    class Foo
    {
       public bool? IsValid { get; set; }
    }
    
    // later in some other function...
    void DoStuff( Foo myFoo )
    {
       myControlState.Visible = myFoo.IsValid.HasValue ? myFoo.IsValid.Value : false;
    }

I run into a lot of situations where I have to use a ternary operator like above to properly use a nullable bool. It would be nice if there was a slightly simpler way of getting the value of the bool without throwing exceptions. The code above seems straight-forward but there are much more complex situations where this ends up being a lot of code. I was hoping for something simple like:

    myControlState.Visible = GetNullableValue<bool>( myFoo );

Does anyone have any cleaner alternatives to the ternary operator?