.NET enumerations in ABL
- Last Updated: November 29, 2021
- 2 minute read
- OpenEdge
- Version 12.2
- Documentation
.NET enumerations in ABL
ABL also views a .NET enumeration as a special kind of class, and you can
reference .NET enumeration types and their members like any other .NET class—for example,
MyGraphics.Color:Blue (see the Enumeration member access
reference entry in ABL Reference). However, unlike .NET, which manages
enumerations as values, ABL only references and manages .NET enumeration types and their
values as objects.
So, where .NET languages can view enumeration members as named constants of a common underlying primitive data type, ABL views the members of an enumeration class as objects that refer to but are not equivalent to the underlying primitive type. This means that when you define an ABL variable as a .NET enumeration type, it functions as an object reference, and you can assign it a reference to a .NET enumeration value (member). However, you cannot assign an ABL primitive value to an enumeration variable even if it is equivalent to the underlying primitive value of an enumeration member. In other words, ABL does not map between primitive values and their equivalent enumeration members, as it does with .NET mapped data types (see Implicit data type mappings).
For
example (using our previously defined .NET Color enumeration
example), the following code fragment shows an invalid assignment
to an enumeration variable in ABL:
|
Such an assignment raises a compile-time error, and ABL (unlike .NET languages) provides no way to cast such an assignment.
The following code fragment shows a valid .NET enumeration
type assignment to the same MyGraphics.Color enumeration variable
in ABL:
|
Also, ABL does not support operator overloading for classes the way .NET languages do. So, you cannot directly perform operations on .NET enumeration members using the same operations supported for the underlaying data type of an enumeration.
For example, an expression like the one shown in the following ABL assignment is invalid:
|
However to support such operations on enumeration members, ABL supports a helper class, Progress.Util.EnumHelper, which provides methods that perform common operations on .NET enumerations.