title: How to call generic method of derived class from base class reference in C#
body: <p>I have the following base class (omitted version):</p>
  <pre><code>class BaseClass
  {  
  }
  </code></pre>
  <p>I create the following derived classes:</p>
  <pre><code>class DataPreparationClass&lt;T&gt; : BaseClass
  {
  }
  
  class DataClass&lt;T,U&gt; : DataPreparationClass&lt;T&gt;
  {
    public virtual void Start&lt;U&gt;(U arg)
    {}
  }
  
  class DataClassMain : DataClass&lt;InputData,Data&gt;
  {
    public override void Start(Data argument)
    {
      base.Start(argument);
    }
  }
  
  class DataClassAux : DataClass&lt;InputData,AuxData&gt;
  {
    public override void Start(AuxData argument)
    {
      base.Start(argument);
    }
  }
  </code></pre>
  <p>I have a <code>List&lt;BaseClass&gt;</code> containing <em><strong>various</strong></em> derived instances (there are more derived types) and I intend to call their <code>Start</code> method respectively:</p>
  <pre><code>List&lt;BaseClass&gt; instances = GetAllInstance();
  
  foreach(BaseClass instance in instances)
  {
    object arg = GetArgsForInstance(instance);
    // instance.Start(arg); //can't call this
  }
  </code></pre>
  <p>However, as their common base is the <code>BaseClass</code>, I can't call <code>Start</code> without casting to...basicly every possible type as their types are unknown at the processing.</p>
  <p>If I use <strong>dynamic</strong>:</p>
  <pre><code> ((dynamic)target).Start(new Data(&quot;starting&quot;)); //target is of type DataClassMain&lt;InputData,Data&gt;
  </code></pre>
  <p>I get an exception:</p>
  <blockquote>
  <p>Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'The best
  overloaded method match for
  'Client.DataClass&lt;InputData,Data&gt;.Start(Data)' has some invalid
  arguments'</p>
  </blockquote>
  <p>So how should I call the unknown method?</p>