title: How to call a method in an abstract class
body: <pre><code>public abstract class BaseClass
  {
      protected virtual int getValue() { return 1; }
  }
  </code></pre>
  
  <p>I want to call <code>getValue</code> method.</p>
  
  <pre><code>typeof(BaseClass)
      .GetMethod("getValue", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)
      .Invoke(null, new object[] { });
  </code></pre>
  
  <p>This code has  a error.</p>
  
  <blockquote>
    <p>Non static method requires a target</p>
  </blockquote>
  
  <p>However, I cannot create instance of BaseClass because it is abstract class.
  So, I am using dummy class which extends <code>BaseClass</code>.</p>
  
  <pre><code>class DummyClass : BaseClass { }
  
  typeof(BaseClass)
      .GetMethod("getValue", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)
      .Invoke(new DummyClass(), new object[] { });
  </code></pre>
  
  <p>I don't want to create dummy class every time if possible.</p>
  
  <p>Is there a better way?</p>