title: Closures - Difference between capturing variables and reading them as arguments
body: <p>Let's say we have this class:</p>
  
  <pre><code>// Provides deferred behaviour
  public class Command&lt;TResult&gt;
  {
       private Func&lt;object[], TResult&gt; _executeFunction;
       private object[] _args;
  
       public Command(Func&lt;object[], TResult&gt; execution, params object[] arguments)
       {
            _executeFunction = execution;
            _args = arguments;
       }
  
       public TResult Execute()
       {
            return _executeFunction(_args);
       }
  }
  </code></pre>
  
  <p>What's the difference between these two anonymous functions?</p>
  
  <pre><code>int a = 1;
  int b = 4;
  
  // a and b are passed in as arguments to the function
  Command&lt;int&gt; sum = new Command&lt;int&gt;(args =&gt; (int)args[0] + (int)args[1], a, b);
  
  // a and b are captured by the function
  Command&lt;int&gt; sum2 = new Command&lt;int&gt;(_ =&gt; a + b);
  
  Console.WriteLine(sum.Execute()); //Prints out 5
  Console.WriteLine(sum2.Execute()); //Prints out 5
  </code></pre>
  
  <p>I'm specifically looking for performance differences.</p>
  
  <p>Also, we know that if some class is holding a reference of <code>sum2</code>, then <code>a</code> and <code>b</code> will live beyond the scope they were defined on, probably never getting collected by the GC if the function is still referenced anywhere.</p>
  
  <p>Does the same happen with <code>sum</code>? (Considering the arguments are reference types and not value types as in this example)</p>