title: Trying to understand ?. (null-conditional) operator in C#
body: <p>I have this very simple example:</p>
  
  <pre><code>class Program
  {
      class A
      {
          public bool B;
      }
  
      static void Main()
      {
          System.Collections.ArrayList list = null;
  
          if (list?.Count &gt; 0)
          {
              System.Console.WriteLine("Contains elements");
          }
  
          A a = null;
  
          if (a?.B)
          {
              System.Console.WriteLine("Is initialized");
          }
      }
  }
  </code></pre>
  
  <p>The line <code>if (list?.Count &gt; 0)</code> compiles perfectly which means that if <code>list</code> is <code>null</code>, the expression <code>Count &gt; 0</code> becomes <code>false</code> by default.</p>
  
  <p>However, the line <code>if (a?.B)</code> throws a compiler error saying I can't implicitly convert <code>bool?</code> to <code>bool</code>.</p>
  
  <p>Why is one different from the other?</p>