title: Unable to safely detect null value without nullable warnings
body: <p>I don't quite understand the following nullable warning.</p>
  <p>As you can see, I have part of an expression where <code>sheet</code> is not null, but <code>sheet.Id</code> may be. But why can't I used <code>sheet.Id.HasValue</code> to find out?</p>
  <p><a href="https://i.stack.imgur.com/pStHk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pStHk.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/P2Sfs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/P2Sfs.png" alt="enter image description here" /></a></p>
  <p>I also tried <code>sheet.Id != null</code>, but that gives me a different warning.</p>
  <blockquote>
  <p>Warning   CS8625  Cannot convert null literal to non-nullable reference type.</p>
  </blockquote>
  <p>How can I safely determine if <code>sheet.Id</code> is not null?</p>
  <h3 id="update-2h6c">Update</h3>
  <p>This version actually compiles without warning. But I still don't understand why the other versions give me warnings.</p>
  <pre><code>public Worksheet? GetFirstWorksheet()
  {
      WorkbookPart? workbookPart = Document.WorkbookPart;
      Workbook? workbook = workbookPart?.Workbook;
      if (workbook != null)
      {
          Sheets? sheets = workbook.GetFirstChild&lt;Sheets&gt;();
          Sheet? sheet = sheets?.Elements&lt;Sheet&gt;()
              .FirstOrDefault();
          if (sheet != null &amp;&amp; sheet.Id?.Value != null)
              return ((WorksheetPart)workbookPart!.GetPartById(sheet.Id!)).Worksheet;
      }
      return null;
  }
  </code></pre>