title: How the get derived class type from base class
body: <p>I'm trying to refactor a method which I use in a lot of clases. It's simpler to explain it by an example.</p>
  <p>I have this class:</p>
  <pre><code>    public class TipoPuntoClaveConst
      {
          public const int Insercion = 1;
          public const int DetectorDePaso = 2;
          public const int Sincronizador = 3;
          public const int Extraccion = 4;
  
          public static string GetDescripcion(int IdxTipo)
          {
              var property = typeof(TipoPuntoClaveConst)
                  .GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy)
                  .Where(fi =&gt; fi.IsLiteral &amp;&amp; !fi.IsInitOnly &amp;&amp; (int)fi.GetRawConstantValue() == IdxTipo)
                  .FirstOrDefault();
  
              if (property == null) return string.Empty;
              var name = property.Name;
              return ResourceHelper.GetTraduccion(ResourceHelper.FICHERO.General, name);
          }
      }
  </code></pre>
  <p>In the project, I also have a ResourceFile for localization. The <code>GetDescription</code> method, returns the localized text using the correct property name given a value. You can see an example of use:</p>
  <pre><code>&lt;html&gt;
      &lt;body&gt;
          &lt;select id=&quot;cbTipo&quot;&gt;
              &lt;option value=&quot;@TipoPuntoClaveConst.Insercion&quot;&gt;@TipoPuntoClaveConst.GetDescripcion(TipoPuntoClaveConst.Insercion)&lt;/option&gt;
              ...
          &lt;/select&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>The problem is, that I have to copy-paste that method in all of my const classes. I'm trying to implement this method in a base class, something like:</p>
  <pre><code>public class TipoPuntoClaveConst : ConstMaster {...}
  
  public class ConstMaster {
      public static string GetDescripcion(int IdxTipo)
      {
          var property = typeof(TipoPuntoClaveConst)
              .GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy)
              .Where(fi =&gt; fi.IsLiteral &amp;&amp; !fi.IsInitOnly &amp;&amp; (int)fi.GetRawConstantValue() == IdxTipo)
              .FirstOrDefault();
  
          if (property == null) return string.Empty;
          var name = property.Name;
          return ResourceHelper.GetTraduccion(ResourceHelper.FICHERO.General, name);
      }
  }
  </code></pre>
  <p>But I cannot figure out, how to replace <code>var property = typeof(TipoPuntoClaveConst)</code>, for something more general, like  <code>var property = typeof(¿this?)</code></p>