title: How can I use generic polymorphism on a List<BaseClass> containing any child of the base class for my specific code design?
body: <h2>Context</h2>
  <p>I have an abstract parent class, <code>Register</code>, and two interfaces which require the implementation of the generic delegates <code>Func&lt;T&gt;</code> and <code>Action&lt;T&gt;</code> respectively:</p>
  <pre class="lang-cs prettyprint-override"><code>public abstract class Register
  {
      public int Address { get; protected set; }
      public string ID { get; protected set; }
  
      public abstract Type TargetType { get; }
      public abstract bool TargetIsArray { get; }
  }
  
  public interface IReadableRegister&lt;T&gt;
  {
      Func&lt;T&gt; GetAccessor { get; }
  }
  
  public interface IWritableRegister&lt;T&gt;
  {
      Action&lt;T&gt; SetAccessor { get; }
  }
  </code></pre>
  <p>These are used to define a number of sub-classes, such as:</p>
  <pre class="lang-cs prettyprint-override"><code>public class FooRegister&lt;T&gt; : Register, IReadableRegister&lt;T&gt;
  {
      public override Type TargetType =&gt; typeof(T);
      public override bool TargetIsArray =&gt; TargetType.IsArray;
      public Func&lt;T&gt; GetAccessor { get; }
      // Further unique members
  
      public FooRegister(int address, object target, PropertyInfo targetProperty)
      {
          this.Address = address;
          this.ID = targetProperty.Name;
          this.GetAccessor = (Func&lt;T&gt;)targetProperty.GetMethod.CreateDelegate(typeof(Func&lt;T&gt;),target);
      }
  }
  
  public class BarRegister&lt;T&gt; : Register, IWritableRegister&lt;T&gt;
  {
      public override Type TargetType =&gt; typeof(T);
      public override bool TargetIsArray =&gt; TargetType.IsArray;
      public Action&lt;T&gt; SetAccessor { get; }
      // Further unique members
  
      public BarRegister(int address, object target, PropertyInfo targetProperty)
      {
          this.Address = address;
          this.ID = targetProperty.Name;
          this.SetAccessor = (Action&lt;T&gt;)targetProperty.SetMethod.CreateDelegate(typeof(Action&lt;T&gt;),target);
      }
  }
  </code></pre>
  <h2>Usage</h2>
  <p>Using reflection, I build a <code>List&lt;Register&gt;</code> which ultimately provides a collection Get/Set delegates for the public properties of a target object (by a number a criteria irrelevant to this question). I wish to be able to index this <code>List&lt;Register&gt;</code> by <code>ID</code> (easily done) in order to then invoke the <code>GetAccessor</code> and/or <code>SetAccessor</code> as required.</p>
  <h2>Problem</h2>
  <p>I have so far failed to handle an element returned from the <code>List&lt;Register&gt;</code> as the specific generic type it was upon addition, since any cast requires me to use the variable <code>Register.TargetType</code> and generics must be typed at compile time.</p>
  <h2>Question(s)</h2>
  <p>I am aware of possible solutions to the issue such as that detailed here <a href="https://stackoverflow.com/questions/2604743/setting-generic-type-at-runtime">Setting generic type at runtime</a> and also <code>dynamic</code> usage, however I feel that my approach is fundamentally flawed. How else might this functionality be achieved? Surely generics with polymorphic types are regularly handled?</p>