ABL allows you to override properties defined with the virtual modifier in .NET super classes. The following rules apply when overriding .NET virtual properties:
  • The data types of the subclass and super class properties must be compatible.
  • The overriding property in the subclass cannot have a more restrictive access mode than the property in the super class. For example, if the super class property is PUBLIC, then the subclass overriding property cannot be marked PROTECTED. This rule applies to the property itself and the specified accessors (GET/SET).
  • You can override a property that is marked virtual as long as it is not marked sealed lower in the hierarchy.

For information on overriding ABL properties, see Override properties within a class hierarchy.

Example

The following example code shows a property being overridden. class1 is a .NET class with a virtual property called myProp. class2 inherits class1 and myprop is overridden. The example also illustrates that you can use the SUPER system reference to access the property in the super class.
class class1
{
  private int _myValue;
  protected virtual int myProp
  {
    get { return _myValue; }
    set { _myValue = value; }
  }
}
CLASS class2 INHERITS class1:
  DEFINE PROTECTED OVERRIDE PROPERTY myProp AS INT
  GET().
    RETURN SUPER:myProp.
  END.
  SET(INPUT pValue AS INT).
    /* default value to 10 if smaller */
    IF pValue < 10 THEN
      pValue = 10.
    SUPER:myProp = pValue.
  END SET.
END CLASS.