indexers_indexed_property
This is an old revision of the document!
Indexers and indexed properties
Indexers are a new concept for xBase developers. They permit to access the properties of an object like an array. Please see this sample class:
class IndexerTest protect oValues as List<string> constructor() oValues := List<string>{} return property self[ nIndex as int ] as string get if oValues:Count >= nIndex return oValues[nIndex-1] else return "" endif end get set while oValues:Count < nIndex oValues:Add( "" ) end oValues[nIndex-1] := value end set end property end class
This class can be used like this:
function Start( ) as void local oTest as IndexerTest local nI as int oTest := IndexerTest{} oTest[1] := "Chris" oTest[2] := "Fabrice" oTest[3] := "Nikos" oTest[4]:= "Robert" for nI := 1 upto 5 Console.WriteLine( i"Element {nI}:" + oTest[nI] ) next return
Please see also this Microsoft article: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/indexers/
And there is also a forum thread about this: Please see https://www.xsharp.info/forum/public-product/839-indexer-syntax
indexers_indexed_property.1536468688.txt.gz · Last modified: 2018/09/09 04:51 by wolfgangriedmann