小编inc*_*ete的帖子

GetProperty("pname")返回null

我想获得动态对象的动态属性的值.这是我的代码..

public string ReturnProperty(object ob, string prop)
{            
    Type type = ob.GetType();
    PropertyInfo pr = type.GetProperty(prop);

    //Here pr is null..Dont know whats wrong

    return pr.GetValue(ob, null).ToString();
}
Run Code Online (Sandbox Code Playgroud)

c# asp.net

18
推荐指数
4
解决办法
2万
查看次数

标签 统计

asp.net ×1

c# ×1