When reflected by interface type, I get only members of a certain type, and not inherited members.
In this simplified example, the program prints only "Name" and not "ItemNumber", "Name", as I expected:
using System; public interface IBasicItem { string ItemNumber { get; set; } } public interface IItem : IBasicItem { string Name { get; set; } } class Program { static void Main(string[] args) { var type = typeof (IItem); foreach (var prop in type.GetProperties()) Console.WriteLine(prop.Name); } }
What is the reason for this? When I inherit the base interface, I say that any of the implementations of my interface must also implement inherited members. In other words, IItem is an IBasicItem. So why doesn't the inherited member appear by reflection?
driis source share