Hi,
What you are refering to is called a indexer. In C# the syntax for an
indexer is like that of a property. The following is the indexer that takes
a int as the index and returns an object. Note that the indexer is named
this in C#. The type of the index and the return value can be what ever make
sense for your implemetation.
class MyData
{
public virtual object this[int index]
{
get {...}
set {...}
}
}
To use this
MyData d = new MyData()
string s = (string)d[2];
Hope this helps
Chris Taylor
"Chris LaJoie" <ch***@etriptrader.com> wrote in message
news:eB**************@TK2MSFTNGP10.phx.gbl...
I'd like to impliment the same type of functionality the DataRow has as
far as how it uses brackets. I'll give you an example of what I'm looking
for.
DataRow dr = dt.Rows[0];
string aTestVar = (string)dr[0];
...OR...
string aTestVar = (string)dr["aTestColumn"];
How would I impliment this in my own custom types? Thanks.
Chris LaJoie