基类:
public abstract class User
{
//抽象的用户级别,不管子类是什么,总会存在以下用户:
[Description( "用户级别 ")]
public enum UserLevel
{
[Description( "老板 ")]
Boss,
[Description( "系统管理员 ")]
Admin
}
......
}
子类:
public abstract class CompanyUser : User
{
//继承的用户级别,子类是公司,存在以下用户:
[Description( "用户级别 ")]
public enum UserLevel
{
[Description( "默认用户 ")]
Normal,
[Description( "报表用户 ")]
Reporter,
[Description( "主管 ")]
Director,
[Description( "经理 ")]
Manager,
[Description( "财务人员 ")]
Accountant,
[Description( "财务经理 ")]
AccountantManager,
[Description( "老板 ")]
Boss,
[Description( "系统管理员 ")]
Admin
}
......
}
现在的问题是enum类型不能标记为abstract或virtual的,那我如何实现用子类的UsersLevel替换基类的UsersLevel?
换句话说,如何实现以下的代码:
User user = new CompanyUser(); //这句当然没错