C#父类中获取子类的类名

来源:互联网 发布:大富豪3.29全套源码 编辑:程序博客网 时间:2024/05/23 00:58

.父类里 直接 this.GetType().Name


获取到子类,就可以得到子类的Attribute

例如 

 Type chindType = this.GetType() ;//获取子类的类型 childAttr = Attribute.GetCustomAttribute(chindType, typeof(childClassLoginAttribute), false) as childClassLoginAttribute;  //childClassLoginAttribute为自定义的Attribute


0 0
原创粉丝点击