Thanks, but I couldn't quite seem to implement your suggestion. Here's what
I want to do - make a class that's derived from ArrayList and contains an
array of CAccount objects. I tried this:
class CAccounts : ArrayList
{
public override CAccount this[ int iIndex]
{
get { List[iIndex]; }
set { List[iIndex]; }
}
}
But that resulted in the following error:
'HAPTimeClock.CAccounts.this[int]: type must be 'object' to match overriden
member 'System.Collections.ArrayList.this[int]
I tried several more variations but nothing seemed to make the C# compiler
happy.
--
Richard Lewis Haggard
"Daniel O'Connell [C# MVP]" <onyxkirx@--NOSPAM--comcast.net> wrote in
message news:OQ**************@TK2MSFTNGP12.phx.gbl...
"Richard Lewis Haggard" <HaggardAtWorldDotStdDotCom> wrote in message
news:OV**************@TK2MSFTNGP10.phx.gbl... What is the syntax to over ride the array index operator '[]'?
I want to derive a class from CollectionBase and have it encapsulate an
array of another class I'm working with. Among other things, it needs to
over ride the [] operator but I don't seem to be able to get the syntax
quite right. Can someone tell me what the syntax should be in order to
over ride the operator[]?
You have to define an indexer:
public <type> this[<parameter list>]
{
get { }
set { }
} --
Richard Lewis Haggard