标题:请教一下关于特性里的问题代码解释
取消只看楼主
cj604112135
Rank: 1
等 级:新手上路
帖 子:72
专家分:0
注 册:2011-10-8
结帖率:63.64%
已结贴  问题点数:13 回复次数:2 
请教一下关于特性里的问题代码解释
namespace PB_Inherited
{
    class Program
    {
        static void Main(string[] args)
        {
            BaseClass b = new BaseClass();
            DerivedClass d = new DerivedClass();
            Console.WriteLine("基类中的特性:");
            object[] attrs = b.GetType().GetCustomAttributes(true);
            foreach (var attr in attrs)
            {
                Console.WriteLine(attr);
            }

        }
        [AttributeUsage(AttributeTargets.Class,Inherited=true)]
        class A1Attribute :System .Attribute { }
        class A2Attribute : System.Attribute { }
        [A1]
        class BaseClass { }
        class DerivedClass : BaseClass { }

    }
}

object[] attrs = b.GetType().GetCustomAttributes(true);这句话什么意思????????????????
搜索更多相关主题的帖子: class 
2011-12-29 13:06
cj604112135
Rank: 1
等 级:新手上路
帖 子:72
专家分:0
注 册:2011-10-8
得分:0 
object[] attrs = b.GetType().GetCustomAttributes(true);这句话什么意思????????????????
2011-12-29 13:06
cj604112135
Rank: 1
等 级:新手上路
帖 子:72
专家分:0
注 册:2011-10-8
得分:0 
回复 3楼 yhlvht
谢谢
2011-12-29 16:51



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-358842-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.754302 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved