References a property of a class in order to read or write its value.
If an array index is specified, it can be an integer value that identifies an element of an ABL array property, similar to an element of an ABL array data member (see the Class-based data member access reference entry).
If a key for a .NET property indexer is specified, it can be a value of any supported .NET data type that identifies the property value to reference. A .NET indexed property represents a group of properties, where the key is a value that indicates what member of the group is being referenced. A .NET indexed property can have more than one type of indexer that is overloaded according to the data type of its key, similar to a method that is overloaded by a single parameter. However, you cannot specify an AS data type with the key in order to identify a particular .NET indexer overload, as you can with a .NET method parameter (see the Parameter passing syntax reference entry). Also, some .NET indexed properties have indexers with multiple key values, each with its own data type. However, ABL only supports .NET indexed properties that have single-key indexers. So, you might be able to use some indexers for a property and not be able to use others.
Thus, ABL only recognizes a .NET property indexer if the property has a single-key indexer. If so, ABL selects the indexer using the ABL data type that you specify for the key, in order by the following criteria:
For more information on how ABL data types map to .NET data types, see the Data types reference entry.
For example, if you specify an ABL INTEGER value for the key, and the indexer is overloaded by .NET System.Double, System.Byte, and System.Int32 keys, ABL uses the System.Int32key to index the property. If the available overloadings are System.Double, System.Byte, and System.Int16, ABL uses either the System.Byte or the System.Int16key, which ever is encountered first.
ABL classes do not currently support the definition of indexed properties. So, you cannot access ABL properties using an indexer.
The following code fragment shows a reference to a public instance property (HighCustBalance) on an instance of the sample class, r-CustObj:
DEFINE VARIABLE rObj AS CLASS r-CustObj NO-UNDO. rObj = NEW r-CustObj( ) NO-ERROR. MESSAGE "High customer balance =" rObj:HighCustBalance VIEW-AS ALERT-BOX. |
Once initialized, this instance property returns the highest balance for all Customer records in the sports2000 database.
The following code fragment shows a reference to a public static property (HighCustBalance) on the sample class type, r-CustObjStatic:
This static property similarly returns the highest balance for all Customer records in the sports2000 database without having to instantiate the class, as in the previous instance code.
For more information on these properties and the sample classes in which they are defined, see the examples in the CLASS statement reference entry.
For more information on accessors for a .NET property, see its entry in Microsoft .NET, Infragistics, or another class library that defines the property. In C# documentation, the presence of a get accessor in the property signature means that the property is readable; the presence of a set accessor in the property signature means that the property is writable. For example, the signature of the .NET HelpButton property indicates that it is both readable and writable, because it shows both a get and a set accessor:
DEFINE VARIABLE rDataView AS CLASS System.Data.DataView. DEFINE VARIABLE rRow AS CLASS System.Data.DataRow. . . . rRow = rDataView[2]. rRow = rDataView:Item[2]. |
In .NET, the most common use of a default indexed property is to access an instance of a class from a collection. Two examples are the .NET System.Data.DataTableCollection and the System.Data.DataRow classes. For more information on working with .NET collections in ABL, see OpenEdge Development: GUI for .NET Programming.