views:

14

answers:

1

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)?

+1  A: 

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.

Justin Niessner
If I do this:PropertyInfo[] pi = typeof (IEnumerable).GetProperties();it's returns 0 elements.IEnumerable needed to store records in a table and I need to read all columns and records from it.
Dublicator
@Dublicator - That's because IEnumerable has no properties. It only contains a single method for getting the Enumerator.
Justin Niessner