title: Where is the instance of "IntConverter" stored?
body: <p>Let's suppose we have the following program:</p>
  
  <pre><code>public class Program
  {
      private static Dictionary&lt;Type, Func&lt;object, object&gt;&gt; converters = new Dictionary&lt;Type, Func&lt;object[], object&gt;&gt;();
  
      public static void Main(string[] args)
      {
           RegisterImplementation(new IntConverter());
           int value = (int) dic[typeof(int)]("4");
           Console.WriteLine(value); //Prints 4
      }
  
      private static RegisterImplementation&lt;X&gt;(IConverter&lt;X&gt; converter)
      {
           Type type = typeof(X);
           Func&lt;object, object&gt; conversion = (obj) =&gt; converter.Convert(obj);
           if(dic.ContainsKey(type))
               dic[type] = conversion;
           else
               dic.Add(type, conversion);
      }
  }
  
  public interface IConverter&lt;X&gt;
  {
      X Convert(object obj);
  }
  
  public class IntConverter : IConverter&lt;int&gt;
  {
      public int Convert(object obj)
      {
          return Convert.ToInt32(obj);
      }
  }
  </code></pre>
  
  <p>I understand most of the code, but the part that's driving me mad is the <code>RegisterImplementation</code> method. In the dictionary we are storing a <code>Func&lt;object, object&gt;</code> instance, and the <code>converter</code> is not stored anywhere, so I am assuming we lose the local reference when we get out of the method.</p>
  
  <p>So how can we call the function in the dictionary afterwards and use this reference of <code>IntConverter</code>? Where is it stored? Inside the <code>Func&lt;object, object&gt;</code>?</p>