在 VB.NET 中重载枚举和属性
我有一个具有以下枚举和属性的基类:
Public Enum InitType
Focus = 0
Help = 1
ErrorToolTip = 2
End Enum
Property ToolTipInitType() As InitType
Get
Return m_initType
End Get
Set(ByVal value As InitType)
m_initType = value
End Set
End Property
我想创建一个扩展枚举的派生类,因此派生类枚举将是:
Public Enum InitType
Focus = 0
Help = 1
ErrorToolTip = 2
HelpPopUp = 3
End Enum
首先,我该如何做到这一点 - 是通过简单地重载它吗?其次,在使用派生类时,我的原始属性是否会自动获取新的枚举,还是我也需要重载它?
非常感谢任何帮助。
谢谢
嗅探器
I have a base class with the the following enum and property:
Public Enum InitType
Focus = 0
Help = 1
ErrorToolTip = 2
End Enum
Property ToolTipInitType() As InitType
Get
Return m_initType
End Get
Set(ByVal value As InitType)
m_initType = value
End Set
End Property
I would like to create a derived class which extends the enum, so the derived classes enum would be:
Public Enum InitType
Focus = 0
Help = 1
ErrorToolTip = 2
HelpPopUp = 3
End Enum
First off, how do I do this - is it by simply overloading it? And secondly will my original property pick up the new enum automatically when using the derived class or will I need to overload that too?
Any help greatly appreciated.
Thanks
Sniffer
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有一种继承某些东西的方法与枚举的工作方式几乎相同。就您的代码使用而言,它看起来几乎相同。诀窍是定义一个具有静态/共享字段的类,而不是使用枚举。
在类中使用它时,它具有相同的语法。像这样:
现在要扩展您的“枚举”,您只需执行以下操作:
现在您可以访问包含所有原始值和新值的派生枚举。
There is a way to inherit something that works pretty much the same way as an enum. As far as your code usage goes it looks pretty much the same. The trick is to define a class with static/shared fields rather than using an enum.
This has the same syntax when using it in your class. Like so:
Now to extend your "enum" you simply do this:
Now you can access the derived enum with all of the original values plus the new one.