title: Storing generics temporarily
body: <p>I was wondering in this scenario, if there is any better way of doing things without creating a lot of custom classes for something that should be "generic".
  Can there be any trouble with the dynanmic with this?  </p>
  
  <p>For the lambda version, it will create garbage to reference the updateMethod and the values, right?  </p>
  
  <p>For the dynamic, is there anything bad about it other than a slight decrease in performance and no intellisense and strong typing?  </p>
  
  <p>Storing the values and the updateMethod as objects, and the type of the TVal to cast the objects back to their original type later, feels messy and a lot of casting here and there.</p>
  
  <pre><code>public class Test
  {
      dynamic Values;
      dynamic UpdateMethod;
  
      public void Update&lt;TVal&gt;(TVal[] values, Action&lt;int, TVal&gt; updateMethod) 
          where TVal : class
      {
          // lambda
          Parallel.For(0, values.Length, (i) =&gt; { updateMethod(i, values[i]); });
  
          // vs
  
          // dynamic
          Values = values;
          UpdateMethod = updateMethod;
  
          Parallel.For(0, values.Length, Work);
      }
  
      void Work(int i)
      {
          UpdateMethod(i, Values[i]);
      }
  }
  </code></pre>
  
  <p>And, additionally, why exactly doesn't this work.<br>
  <code>Action&lt;int, dynamic&gt; UpdateMethod = updateMethod;</code></p>
  
  <p>Why I ask these questions? Curiosity and always good to expand knowledge, why, if it is good and or bad.<br>
  + how would one search for this, if someone else has posted it online, I can't find any search parameters.</p>
  
  <p>Sorry if the title, or the questions don't fit stackoverflow, I don't know where else to ask.</p>