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)?
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.
精彩评论