INDEXER (CLASS index)

Top  Previous  Next

 

INDEXER

 

INDEXER - An indexer enables you to use an index on an object to obtain values stored within the object. An indexer is also similar to a property, as with properties you use getters and setters when defining an indexer.

 

Example:

 

IndexerCl CLASS<t>,PUBLIC,NETCLASS

Arr        t[],PRIVATE

INDEXER(INT32 index),t,PUBLIC

Construct  PROCEDURE()

         END

 

IndexerCl<t>.Construct PROCEDURE()

CODE

 SELF.arr = new t[30]

 RETURN

 

IndexerCl<t>.GET_Indexer PROCEDURE(INT32 index)

CODE

 RETURN SELF.Arr[index]

 

IndexerCl<t>.SET_Indexer PROCEDURE(INT32 index, t value)

CODE

 SELF.Arr[index] = value

 

 

See Also: INLINE, PROPERTY