title: Access closure variables in func delegate c#
body: <pre><code>public Func&lt;string, string&gt; getdel()
  {
      int i = 1;
      int j = 1;
      return s =&gt; s.ToUpper() + (i++);
  }
  
  public Func&lt;string, string&gt; aa = getdel()
  aa("Test");
  </code></pre>
  
  <p>Closure variable's value is returned in Target property of delegate.How can I access the closure variable value?something like this:</p>
  
  <pre><code>((appropriatecast)(aa.Target)).i
  </code></pre>
  
  <p>When hitting breakpoint at delegate ,I can see the value of i but in code this <code>appropriatecast</code> is a  <code>&lt;&gt; c__DisplayClass2_0</code> that is compiler generated(verified from IL Disassembler). </p>