title: `Activator.CreateInstance` and `new` properties in derived types
body: <p>I have the following classes:</p>
  
  <pre><code>public class HeaderBase
  {
      public int HeaderSize { get { return sizeof(byte); } }
      public byte[] Content { get; private set; }
  
      public HeaderBase(byte[] bytes)
      {
          Content = bytes;
      }
  }
  
  public class BiggerHeader : HeaderBase
  {
      public new int HeaderSize { get { return sizeof(byte) + sizeof(UInt32); } }
  
      public BiggerHeader(HeaderBase header) : base(header.Content)
      { }     
  }
  </code></pre>
  
  <p>I also have a templated method to marshal and instantiate the <code>BiggerHeader</code> type</p>
  
  <pre><code>public static T Get&lt;T&gt;() where T : HeaderBase
  {
      HeaderBase b = new HeaderBase(new byte[]{});
      T instance = (T)Activator.CreateInstance(typeof(T), b);
      return instance;
  }
  </code></pre>
  
  <p>According to <a href="https://msdn.microsoft.com/en-us/library/d5x73970.aspx" rel="nofollow noreferrer">MSDN</a>:</p>
  
  <blockquote>
    <p><code>where T : &lt;base class name&gt;</code>: The type argument must be or <strong>derive</strong> from the specified base class.</p>
  </blockquote>
  
  <p>However, the value of <code>HeaderSize</code> is 1 and not 5 as I would have expected. Why would this be the case, and how can I instantiate an object which will use the <code>new</code> properties from derived types?</p>
  
  <p><a href="https://dotnetfiddle.net/yQqBcI" rel="nofollow noreferrer">DotNetFiddle</a></p>
  
  <p>Related: <a href="https://stackoverflow.com/questions/6410340/generics-in-c-sharp-how-can-i-create-an-instance-of-a-variable-type-with-an-ar">Generics in C# - how can I create an instance of a variable type with an argument?</a></p>