Extending ENUM valus inherited from base object
If I defined a ENUM in a base object with several default values. When I inherit from the base object I want to add more options the the ENUM list which are specific to the inheriting object.
For example my base could have a ENUM called Direction with values:
None ALL Stop StartI create a new class call Compass which inherits the base class and what to add the following to the ENUM Direction.
North South East WestI create a new class call Navigation which inherits the base cl开发者_运维知识库ass and what to add the following to the ENUM Direction.
Left RightSo, In my inheriting class haow do I extend the ENUM. I am using VB.NET.
You can't do that since enums are value types and so are sealed.
Though he's a codeproject article that tries to work around that: http://www.codeproject.com/KB/cs/EnumBuilder.aspx
精彩评论