title: Why compiler throw error CS0165: Use of unassigned local variable?
body: <p>I put the code below, and also uploaded to a online c# compiler:
  <a href="http://jdoodle.com/a/1jww" rel="noreferrer">jdoodle.com/a/1jww</a>
  the code can compile and run online, however, it doesn't compile in my local visual studio.</p>
  
  <p>I am using:</p>
  
  <blockquote>
    <p>Visual Studio 2017 15.9.13,</p>
    
    <p>Console app, .Net Framework 4.7.2</p>
    
    <p>Language version c# 7.3</p>
    
    <p>Microsoft (R) Visual C# Compiler version 2.10.0.0 (b9fb1610)</p>
  </blockquote>
  
  <p>Below is the code:</p>
  
  <pre><code>class Program
  {
      static void Main()
      {
          Dictionary&lt;string,int&gt; myDict = new Dictionary&lt;string,int&gt;();
          myDict.Add("hello", 1);
  
          if (myDict?.TryGetValue("hello", out var value) == true)
          {               
              Console.WriteLine("Hello" + value.ToString());
          }
      }
  }
  </code></pre>
  
  <p>expecting to see Hello1 in Console.Output
  Because if the condition is true, the Null-Conditional check must have returned a non-null value, and the key is existing in the dictionary and the value must have been assigned when returning from the TryGetValue method.</p>
  
  <p>Because according to <a href="https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/out-parameter-modifier" rel="noreferrer">the documentation</a>:</p>
  
  <blockquote>
    <p>the called method is required to assign a value before the method returns.</p>
  </blockquote>
  
  <hr>
  
  <p>update:
  This is an open issue in <a href="https://github.com/dotnet/roslyn/issues/32572" rel="noreferrer">https://github.com/dotnet/roslyn/issues/32572</a><br/>
  I think it's an true issue/bug if the requirement for compiler includes not to give false alarm. 
  My arguments: <br/>
  Whenever CPU executing to the point inside the if bracket code block, the value must have returned from TryGetValue call and is NOT "unassigned local variable". An easier solution is to give something like "unable to determine assignment status" as warning instead of error, if compiler can't look forward for assignment status when interpreting null conditional operator. </p>