[英]How to get nested level of property class by reflection in .net
Class A
{
public B child {get; set;}
}
Class B
{
public string childProperty {get; set;}
}
I am getting all property 我得到所有财产
var BType = AType.GetType().GetProperty("child");
I am able to get "Child" property of A, but how i can get "childProperty" from BType? 我可以获取A的“ Child”属性,但是如何从BType获取“ childProperty”?
You can get B
type using BType.PropertyType
: 您可以使用
BType.PropertyType
获得B
类型:
A AType = new A();
var BType = AType.GetType().GetProperty("child");
var childPropertyType = BType.PropertyType.GetProperty("childProperty");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.