title: How to call a function dynamically based on an object type
body: <p>I am looking for an elegant way to call a function based on the type of parameter that is passed as parameter.</p>
  
  <p>In other words, I want the <code>EntryPoint</code> method (below) to dynamically call the appropriate myFunc method, based on the type of the <code>template</code> parameter.</p>
  
  <pre><code>public void EntryPoint(object template)
  {
      missingMethod(template);//This is the code in question that should call myFunc
  }
  
  private void myFunc(TemplateA template)
  {
      doSomething(template);
  }
  
  private void myFunc(TemplateB template)
  {
      doSomethingElse(template);
  }
  
  private void myFunc(object template)
  {
      throw new NotImplementedException(template.GetType());
  }
  </code></pre>