between a property and an indexer
-
hiho, i think those properties are a nice new thing in c#. is there a way to have an array as a property? indexers are on a by-class-basis (so to say), so is there anything between? imagine a table-class. i want something like myTable.RowName[6]="Street"; myTyble.Cell[3,7] = 87; so, how to define RowName or Cell of course i can do it the old-fashioned way using member-functions a la myTable.SetRowname(6,"Street") or the other way around, make the array public, but then the user of my class is responsible for the range-checking. X| ok, the question in short again: can i have an array as a property? if yes, how? thx in advance. :wq
-
hiho, i think those properties are a nice new thing in c#. is there a way to have an array as a property? indexers are on a by-class-basis (so to say), so is there anything between? imagine a table-class. i want something like myTable.RowName[6]="Street"; myTyble.Cell[3,7] = 87; so, how to define RowName or Cell of course i can do it the old-fashioned way using member-functions a la myTable.SetRowname(6,"Street") or the other way around, make the array public, but then the user of my class is responsible for the range-checking. X| ok, the question in short again: can i have an array as a property? if yes, how? thx in advance. :wq
You can define a property that returns a reference to an array. Also, there is nothing stopping you from returning a reference to class that defines an indexer with multiple parameters. Either way, it should work as you stated above... Regards