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 dec
You can specify Type.GetProperties(
BindingFlags.DeclaredOnly)
to get the properties that are defined in the derived class. If you then call GetProperties
on the base class, you can get the properties defined in the base class.
In order to fetch the public properties from your class, you could do:
var classType = typeof(MsClass);
var classProps = classType.GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public);
var inheritedProps = classType.BaseType.GetProperties(BindingFlags.Public | BindingFlags.Instance);