C# – Get subclass properties with reflection
When you use reflection to get properties, you can get just the subclass properties by using BindingFlags.DeclaredOnly (this causes it to exclude inherited properties). Here’s an example: Note: Use GetType() if you have an object. Use typeof() if you have a class. The code outputs just the subclass properties (from the Driver subclass): Get base … Read more