Skip to content

Instantly share code, notes, and snippets.

Created November 10, 2009 23:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/231389 to your computer and use it in GitHub Desktop.
Save anonymous/231389 to your computer and use it in GitHub Desktop.
var properties = TypeDescriptor.GetProperties(typeof(ISuperHero))
.OfType<PropertyDescriptor>()
.Concat(typeof(ISuperHero).GetInterfaces().SelectMany(x => TypeDescriptor.GetProperties(x).OfType<PropertyDescriptor>()));
foreach (PropertyDescriptor property in properties)
{
Console.WriteLine(property.Name);
}
// reflection
var reflectedProperties = typeof(ISuperHero).GetProperties()
.Concat(typeof(ISuperHero).GetInterfaces().SelectMany(x => x.GetProperties()));
foreach (var property in reflectedProperties)
{
Console.WriteLine(property.Name);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment