mardi 12 décembre 2017

Loop through only the properties of a subclass

I have a subclass in WPF that inherits from Button.

I don't want to see the numerous properties of the Button class, I only need my additional properties I've added.

I'm using your typical reflection and, and obviously am getting every property on the object being inherited:

    var properties = type.GetProperties();
    foreach (var prop in properties) {
        Console.WriteLine(prop.Name);
    }

How can I restrict this, or check if it's coming from the sub-class?





Aucun commentaire:

Enregistrer un commentaire