Enumeration Class Restrictions
Enumeration classes restrict certain aspects of their use and definition:
Enumeration classes are implicitly
Sealed. You cannot define a subclass of an enumeration class because doing so would expand the set.
The properties of value-based enumeration classes are immutable. Only the constructor can assign property values. MATLAB® implicitly defines the
SetAccessattributes of all properties defined by value-based enumeration classes as
immutable. You cannot set the
SetAccessattribute to any other value.
All properties inherited by a value-based enumeration class that are not defined as
The properties of handle-based enumeration classes are mutable. You can set property values on instances of the enumeration class. See Mutable Handle vs. Immutable Value Enumeration Members.
An enumeration member cannot have the same name as a property, method, or event defined by the same class or inherited from a superclass. For example, an enumeration class that inherits from a built-in numeric superclass inherits the
fullmethod from the superclass, so "full" is not a valid member name.
Enumerations do not support colon (
a:b) operations. For example,
FlowRate.Low:FlowRate.Highcauses an error even if the
FlowRateclass derives from a numeric superclass.
Classes that define enumerations cannot restrict properties of the same class to an enumeration type. Create a separate enumeration class to restrict property values to an enumeration. For information on restricting property values, see Example of Restricted Property.
If the primary enumeration member sets the
Hiddenattribute, then the secondary member (one with the same underlying value) must also set the
Hiddenattribute. For more information, see Hide Enumeration Members.