第11章例程WhatsNewAttributes中有如下代码:        static void DisplayTypeInfo(Assembly theAssembly, Type type)
        {
            .......
            Attribute[] attribs = Attribute.GetCustomAttributes(type);
            .......
        }查看msdn,Attribute.GetCustomAttributes 方法的各种重载中没有只接受Type类型参数的版本啊,可是这个程序为什么能通过编译,并正常运行呢?谢谢!

解决方案 »

  1.   


        class WhatsNewChecker
        {        
            static void Main()
            {
                Assembly theAssembly = Assembly.Load("VectorClass");
                Type[] types = theAssembly.GetTypes();
                foreach (Type definedType in types)
                    DisplayTypeInfo(theAssembly, definedType);
                ......
            }
            static void DisplayTypeInfo(Assembly theAssembly, Type type)
            {
                .......
                Attribute[] attribs = Attribute.GetCustomAttributes(type);
                .......
            }