| 
       DYNAMIC-CAST( object-reference , expression ).
       | 
 You typically cast an object reference down a class hierarchy—that is, from a super class to a derived class within a class hierarchy, or from an interface to a class that implements that interface. However, you do not always need to explicitly cast an object reference. Because a derived class contains all the super classes in its inherited class hierarchy, ABL implicitly casts any object reference up within its class hierarchy, and because a class that implements an interface implements all of the methods specified for the interface, ABL implicitly casts any object reference from an implementing class to any interface that the class implements.
You typically cast an object reference down a class hierarchy—that is, from a super class to a derived class within a class hierarchy, or from an interface to a class that implements that interface. However, you do not always need to explicitly cast an object reference. Because a derived class contains all the super classes in its inherited class hierarchy, ABL implicitly casts any object reference up within its class hierarchy, and because a class that implements an interface implements all of the methods specified for the interface, ABL implicitly casts any object reference from an implementing class to any interface that the class implements.
   At run time, ABL verifies that the object type specified by expression is within the class hierarchy of the specified object reference. Therefore, if you access a class member on the cast object reference that exists for the cast data type, but the referenced object does not actually define the accessed class member, the AVM raises a run-time ERROR.
At run time, ABL verifies that the object type specified by expression is within the class hierarchy of the specified object reference. Therefore, if you access a class member on the cast object reference that exists for the cast data type, but the referenced object does not actually define the accessed class member, the AVM raises a run-time ERROR.
   A .NET generic type can be part of a cast. For example, you can cast from a System.Object to a "System.Collections.Generic.List<SHORT>", because all .NET classes, including generic classes, derive from the .NET root class. However, note that you cannot cast from a "System.Collections.Generic.List<System.Object>" to a "System.Collections.Generic.List<System.Windows.Forms.Button>". You cannot assign a "List<Button>" reference to an object reference defined as a "List<Object>", because, even though the type parameters are compatible, the two objects as a whole are not equivalent and have no inheritance relationship. Therefore, a cast between these two objects cannot work either. For more information on .NET generic types, see the Data types reference entry.
A .NET generic type can be part of a cast. For example, you can cast from a System.Object to a "System.Collections.Generic.List<SHORT>", because all .NET classes, including generic classes, derive from the .NET root class. However, note that you cannot cast from a "System.Collections.Generic.List<System.Object>" to a "System.Collections.Generic.List<System.Windows.Forms.Button>". You cannot assign a "List<Button>" reference to an object reference defined as a "List<Object>", because, even though the type parameters are compatible, the two objects as a whole are not equivalent and have no inheritance relationship. Therefore, a cast between these two objects cannot work either. For more information on .NET generic types, see the Data types reference entry.
   You can also use the CAST function to perform all casting operations at compile time. The primary reason for using the DYNAMIC-CAST function is to cast object references based on run-time conditions that determine the object type to use for the cast. Such conditions are common in applications that conform to the OpenEdge Reference Architecture (OERA). For more information on the OERA, see the Progress Software Developers Network (PSDN): http://communities.progress.com/pcom/community/psdn.
You can also use the CAST function to perform all casting operations at compile time. The primary reason for using the DYNAMIC-CAST function is to cast object references based on run-time conditions that determine the object type to use for the cast. Such conditions are common in applications that conform to the OpenEdge Reference Architecture (OERA). For more information on the OERA, see the Progress Software Developers Network (PSDN): http://communities.progress.com/pcom/community/psdn.
   You can use the DYNAMIC-CAST function to cast a parameter in a parameter list for a method using the following syntax, where expression evaluates to a subclass of the object-reference type:
You can use the DYNAMIC-CAST function to cast a parameter in a parameter list for a method using the following syntax, where expression evaluates to a subclass of the object-reference type:
  | 
       method-name( INPUT DYNAMIC-CAST( object-reference, expression ), ... ).
       | 
 You can use the DYNAMIC-CAST function to cast a temp-table field, which is defined as a Progress.Lang.Object, to use as an object of another class type. For example:
You can use the DYNAMIC-CAST function to cast a temp-table field, which is defined as a Progress.Lang.Object, to use as an object of another class type. For example:
  | 
       DEFINE VARIABLE RCustObj AS CLASS acme.myObjs.CustObj.
        DEFINE TEMP-TABLE mytt NO-UNDO FIELD CustObj AS Progress.Lang.Object. RCustObj = DYNAMIC-CAST(mytt.CustObj, "acme.myObjs.CustObj"). | 
 You cannot use the DYNAMIC-CAST function to cast an object reference to a subclass and invoke a method defined in that subclass using the following syntax:
You cannot use the DYNAMIC-CAST function to cast an object reference to a subclass and invoke a method defined in that subclass using the following syntax:
  | 
       DYNAMIC-CAST( object-reference, object-type-name ):method-name( 
        parameters ). |