ITPub博客

首页 > > > BCL里有Property这个类吗

BCL里有Property这个类吗

作者:dapan 时间:2019-09-23 15:18:25 0 删除 编辑

我看到有大虾写过的一个扩展类,BCL里有Property这个类吗,求解答。

public static class PropertyExtension

{

public static object GetValueByName(this object self, string propertyName)

{

if (self == null)

{

return self ;

}

Type t = self.GetType();

PropertyInfo p = t.GetProperty(propertyName);

return p.GetValue(self, null);

}

}


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/758/viewspace-3161244/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2020-08-07

  • 博文量
    4504
  • 访问量
    87401