Anton Kandybo
Anton Kandybo

Reputation: 4098

IEnumerable.GetProperties()

I have class Foo, which derived from interface IFoo and IEnumerable

public class Foo:IFoo,IEnumerable
{
   public decimal Count {...}
   ///etc...
}

How to call GetProperties(), that it's return only public properties of IEnumerable (not IFoo or this class)?

Upvotes: 0

Views: 468

Answers (1)

Justin Niessner
Justin Niessner

Reputation: 245509

To get the properties of IEnumerable, you don't even need to reference Foo:

typeof(IEnumerable).GetProperties();

Once you have the properties and you're ready to get values using the PropertyInfo object, then you can pass it an instance of the Foo class to get the values from.

Upvotes: 1

Related Questions