title: "Use of unassigned local variable" error even though I assign the variable?
body: <p>In the example below, the compiler generates an error "Use of unassigned local variable <code>r</code>", even though I assign the variable in loop before using it. Why does the compiler generate this error?</p>
  
  <pre><code>static void Main(string[] args)
  {
      float r;
  
      for (int i = 0; i &lt; 100; i++)
          r = i; // assigned here
  
      Console.WriteLine(r); // error: use of unassigned local variable            
  }
  </code></pre>