Indexed property overloading
- Last Updated: January 17, 2024
- 2 minute read
- OpenEdge
- Version 12.8
- Documentation
Indexed property overloading
Unlike the case for an ABL array index, the data type
of an indexed property's key does not have to be an INTEGER. Also, .NET allows
overloaded indexed properties within a class that are distinguished
by the data type of the index key, similar to parameter data types
of overloaded methods. For example in ABL, the default indexed property
of the Control+ControlCollection class can be indexed by
either an INTEGER or a CHARACTER (or LONGCHAR)
data type.
Note that some ABL data types map implicitly to more than one .NET data type.
This affects how ABL identifies the indexed property to access.
If a property indexer key is overloaded by multiple .NET data
types that implicitly map to a single ABL data type, and you specify
an indexer using that ABL data type, ABL uses the indexer key whose .NET data
type is the default match for the ABL data type. For example, if
an indexed property key is overloaded by the C# data types short and int (both
of which map to INTEGER in ABL), ABL always accesses
the property by the int key. However, if there
is no key defined with the default matching data type, ABL chooses
the first key that it encounters that is an implicit match for the
specified ABL data type.
You also
cannot disambiguate overloaded indexed property keys using the
ASdata-type option that is available for method
parameters (see Specify .NET constructor and method parameters). Using this option on property index keys raises a compile-time
error.
ABL also respects data type widening for the match. For more information on .NET data type mappings and the default matches for ABL data types, see Use .NET data types in ABL.