反射属性名称,属性名称不区别大小写

PropertyInfo pi = typeof(object).GetProperty("PropertyName", BindingFlags.IgnoreCase);

这样是获取不出来的,得加上 BindingFlags.Public | BindingFlags.Instance

如下这样就可以了。

PropertyInfo pi = typeof(object).GetProperty("PropertyName", BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);


相关文章:

  • 2021-08-30
  • 2021-12-10
  • 2021-08-05
  • 2021-08-16
  • 2022-12-23
  • 2021-07-15
  • 2022-12-23
猜你喜欢
  • 2021-05-19
  • 2022-12-23
  • 2022-12-23
  • 2022-02-14
  • 2021-08-20
  • 2021-07-09
相关资源
相似解决方案