首页 > 其他 > 详细

Type.GetField 修改类中私有字段。

时间:2015-05-08 12:38:46      阅读:221      评论:0      收藏:0      [点我收藏+]

上一篇Popup Bug中修改了SystemParameters类中静态只读属性MenuDropAlignment。

技术分享

                var t = typeof(SystemParameters);
                var field = t.GetField("_menuDropAlignment", BindingFlags.NonPublic | BindingFlags.Static);
                field.SetValue(null, false);

  其中 _menuDropAlignment 为SystemParameters中的静态 私有字段。通过Type.GetField反射出该字段并进行修改。。

  

     这样SystemParameters类中的只读属性就得到了修改

 

Type.GetField 修改类中私有字段。

原文:http://www.cnblogs.com/m7777/p/4487192.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!