title: How to find out if property is inherited from a base class or declared in derived?
body: <p>I have a class that is derived from an abstract class. Getting a type of a derived class I want to find out which properties are inherited from abstract class and which were declared in  the derived class. </p>
  
  <pre><code>public abstract class BaseMsClass
  {
      public string CommonParam { get; set; }
  }
  
  public class MsClass : BaseMsClass
  {
      public string Id { get; set; }
      public string Name { get; set; }
  
      public MsClass()
      { }
  }
  
  var msClass = new MsClass
  {
      Id = "1122",
      Name = "Some name",
      CommonParam = "param of the base class"
  };
  </code></pre>
  
  <p>So, I would like to quickly find out that CommonParam is an inherited parameter and Id, Name are params declared in MsClass. Any suggestions?</p>
  
  <p>Attempt to use declared only flag returns me empty PropertyInfo array </p>
  
  <pre><code>Type type = msClass.GetType();
  type.GetProperties(System.Reflection.BindingFlags.DeclaredOnly)
  
  --&gt;{System.Reflection.PropertyInfo[0]}
  </code></pre>
  
  <p>However, GetProperties() returns all properties of inheritance hierarchy.</p>
  
  <pre><code>type.GetProperties()
  
  --&gt;{System.Reflection.PropertyInfo[3]}
  --&gt;[0]: {System.String Id}
  --&gt;[1]: {System.String Name}
  --&gt;[2]: {System.String CommonParam}
  </code></pre>
  
  <p>Did I miss something?</p>