Main Content

Default Methods for an Enumeration

By default, MATLAB® provides the following methods for a .NET enumeration:

  • Relational operators — eq, ne, ge, gt, le, and lt.

  • Conversion methods — char, double, and a method to get the underlying value.

  • Bitwise methods — Only for enumerations with the System.Flags attribute.

For example, type:

methods('System.DayOfWeek')
Methods for class System.DayOfWeek:

CompareTo    eq
DayOfWeek    ge
Equals       gt
GetHashCode  int32
GetType      le
GetTypeCode  lt
ToString     ne
char
double

The method to get the underlying value is int32.

The NetDocEnum.MyDays enumeration, which has the Flags attribute, has the bitwise methods. To list the methods, type:

methods('NetDocEnum.MyDays')
Methods for class NetDocEnum.MyDays:

CompareTo    char         
Equals       double       
GetHashCode  eq           
GetType      ge           
GetTypeCode  gt           
MyDays       int32        
ToString     le           
bitand       lt           
bitnot       ne           
bitor        
bitxor

Related Examples

More About