开发者

IEnumerable.GetProperties()

开发者 https://www.devze.com 2023-01-17 05:46 出处:网络
I have class 开发者_运维技巧Foo, which derived from interface IFoo and IEnumerable public class Foo:IFoo,IEnumerable

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消