GetCustomAttributes方法
public abstract object[] GetCustomAttributes(bool inherit);
这是GetCustomAttributes方法的一个重载,参数为bool类型
返回一个object数组,用以保存对象中的自定义属性(attribute)
参数为true时包括子类中的自定义属性
这是我的理解
可是具体用起来不太明白
比如下面一段代码
Book book = new Book(); //声明一个Book类的实例book
Type type = book.GetType(); //获取book实例的类型
TableAttribute tableAttribute = (TableAttribute)type.GetCustomAttributes(false)[0];
GetCustomAttributes方法为什么要用在type后面呢? 为什么要先获取book实例的类型?
这点我怎么也想不明白,求教各位前辈。。。