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.

  • Bit-wise 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 bit-wise 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

For more information about bit-wise operators, see Use Bit Flags with .NET Enumerations.

Was this topic helpful?