首页 > Web开发 > 详细

.net 简单反射应用

时间:2017-08-15 15:54:32      阅读:253      评论:0      收藏:0      [点我收藏+]

var attributes = typeof(MyClass).GetCustomAttributes(typeof(TestAttribute), true); //MyClass 表示引用特性的类 TestAttribute特性定义的类
foreach (var attribute in attributes)
{
     TestAttribute myAttribute = attribute as TestAttribute;
     if (myAttribute != null)
     {
          Console.WriteLine(myAttribute.Msg);
     }
}

.net 简单反射应用

原文:http://www.cnblogs.com/huguole/p/7365399.html

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