title: Local variable might not be initialized before accessing - after calling .TryParse()
body: <p>I have this piece of code:</p>
  
  <pre><code>var kv = new Dictionary&lt;int, string&gt;() { ... };
  
  var kv30Valid = kv.ContainsKey(30) &amp;&amp; int.TryParse(kv[30], out var kv30Value);
  
  myObject.nullableInt = kv30Valid ? (int?)kv30Value : null;
  </code></pre>
  
  <p>Note: myObject is a POCO class representing a table row, that's why nullable int.</p>
  
  <p>I cannot compile my code because I get compiler error on the last line:</p>
  
  <blockquote>
    <p>Local variable 'kv30Value' might not be initialized before accessing</p>
  </blockquote>
  
  <p>In which case can it be unintialized and how to properly handle the case to allow valid code?</p>
  
  <p>I need to populate the myObject properties with values from the kv (if they are present) parsed to their respective values.</p>
  
  <p><strong>Solution:</strong>
  Moving the condition into TryParse() method solved the problem.</p>
  
  <pre><code>var kv30Valid = int.TryParse(kv.ContainsKey(30) ? kv[30] : null, out var kv30Value);
  </code></pre>