mardi 2 janvier 2018

How to exclude properties of father class

Let us say I have the following two classes.

  public class Father
    {
        public int Id { get; set; }
        public int Price { get; set; } 
    }
    public class Child: Father
    {
        public string Name { get; set; }
    }

How can I know if a specific property is a Father property or Child property?

I tried

var childProperties = typeof(Child).GetProperties().Except(typeof(Father).GetProperties());

but seems like Except is not detecting the equality of Father properties and Child inherited properties.





Aucun commentaire:

Enregistrer un commentaire