title: How to provide the Default value to a boolean property when it was null
body: <p>In the below code i am getting an exception because <code>&quot;isValid&quot;</code> is coming as <code>null</code> from the input request.</p>
  <p>I want to set <code>&quot;isValid&quot;</code> to <code>&quot;False&quot;</code> when it was <code>null</code> from the input request.</p>
  <p>Can anyone pls suggest me how i can do this ?</p>
  <pre><code>public class Details
  {
      public string status { get; set; }
      public MessageInfo messageInfo { get; set; }
  }
  
  public class MessageInfo
  {
      public bool isValid { get; set; }
  }
  
  var inputMessage =
  {
      &quot;Body&quot;:
      {
       &quot;status&quot;:&quot;success&quot;,
       &quot;MessageInfo&quot;: 
        {
          &quot;isValid&quot;:null
        }
      }
  }
  
  var messagebody = inputMessage.Body.ToObject&lt;Details&gt;();
  
  </code></pre>