DYNAMIC-CAST function

Returns a new object reference to the same class instance as an existing object reference, but with a different data type. This different data type is cast from the object type of the original object reference according to another object type specified by a run-time expression. The object types must be related, where one is a class type and the other is subclass of that class type or where one is an interface type and the other is a class that implements the interface of that type.

When you cast an object reference, ABL treats it as if it referenced an instance of the object type to which it is cast. The underlying class hierarchy of the object instance does not change.

Syntax

DYNAMIC-CAST( object-reference , expression ).
object-reference
An object reference defined with the object type to be cast.
expression
A character expression that evaluates to the fully qualified type name for the ABL or .NET class or interface type to which the object reference is cast. This object type must be a class type in a class hierarchy that includes or implements the object-reference data type or it must be an interface type that the object-reference data type implements. However, the object type cannot be a .NET generic type. Specify an object type name using the syntax described in the Type-name syntax reference entry. Any present USING statement has no effect. If no package is specified, the class or interface name must represent the complete type name.

Notes

See also

CAST function, Type-name syntax, USING statement