Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 589627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:26:38+00:00 2026-05-13T15:26:38+00:00

I have an instance of System.Type that represents an interface, and I want to

  • 0

I have an instance of System.Type that represents an interface, and I want to get a list of all the properties on that interface — including those inherited from base interfaces. I basically want the same behavior from interfaces that I get for classes.

For example, given this hierarchy:

public interface IBase {
    public string BaseProperty { get; }
}
public interface ISub : IBase {
    public string SubProperty { get; }
}
public class Base : IBase {
    public string BaseProperty { get { return "Base"; } }
}
public class Sub : Base, ISub {
    public string SubProperty { get { return "Sub"; } }
}

If I call GetProperties on the class — typeof(Sub).GetProperties() — then I get both BaseProperty and SubProperty. I want to do the same thing with the interface, but when I try it — typeof(ISub).GetProperties() — all that comes back is SubProperty.

I tried passing BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy to GetProperties, since my understanding of FlattenHierarchy is that it’s supposed to include members from base classes, but the behavior was exactly the same.

I suppose I could iterate Type.GetInterfaces() and call GetProperties on each one, but then I would be relying on GetProperties on an interface to never return base properties (since if it ever did, I’d get duplicates). I’d rather not rely on this behavior without at least seeing it documented.

How can I either:

  • Get a list of all the properties on an interface, including those from its base interfaces? Or
  • At least be confident that what I’m seeing is documented behavior that I can rely on, so I can work around it?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T15:26:38+00:00Added an answer on May 13, 2026 at 3:26 pm

    An answer of sorts is to be found in an annotation to the .NET framework version 3.5-specific MSDN page on GetProperties(BindingFlags bindingFlags) :

    Passing BindingFlags.FlattenHierarchy
    to one of the Type.GetXXX methods,
    such as Type.GetMembers, will not
    return inherited interface members
    when you are querying on an interface
    type itself.

    […]

    To get the inherited members, you need
    to query each implemented interface
    for its members.

    Example code is also included. This comment was posted by a Microsoftie, so I would say you can trust it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using NHibernate 3.1. I have a user type that represents a System.Drawing.Image .
I have an instance of System.Type, for which IsArray returns true. How can I
If I have an instance of a System.Timers.Timer that has a long interval -
I have some code using a System.Transactions.TransactionScope , that creating a new instance of
I have an instance of Class A that I want to refer to in
I have a MethodInfo object that represents an explicitly-implemented interface method, as follows. MethodInfo
I have a an object of type Picture that contains a List Comments see
I have: data type (all types are values types) as string (for example: 'System.Boolean'
I have System.Collections.Generic.Dictionary<A, B> dict where A and B are classes, and an instance
I have an instance of a UITableView, and a separate class that adheres to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.