G
Guest
Hello!
I am quite new to C#, and one concept that really gives me a headache is
"indexer". I have gone through the MSDN examples, and, at some level know how
to use indexers. But, the thing is I do not understand the specification that
says something along this line "with indexers you can index objects of a
class like an array". The thing is, in all the examples, there is only one
"new" call when only one object is created! There is no array of objects.
Yet, right after the "new" call, indexer is used, like obj[0], obj[1],
obj[2], ..., objNo. When these objects are instantiated? Also, I have tried
printing messages through contructor, hoping that array-like reference
through the indexer will invoke a constructor for each object in the array,
but it did not. Only once that happened when the object is first (and only
time, it appears) was created.
Any explanation? Is there arereally "n" objects created from the class that
has declared an "indexer"?
Thanks for the help!
Nash,
Toronto
I am quite new to C#, and one concept that really gives me a headache is
"indexer". I have gone through the MSDN examples, and, at some level know how
to use indexers. But, the thing is I do not understand the specification that
says something along this line "with indexers you can index objects of a
class like an array". The thing is, in all the examples, there is only one
"new" call when only one object is created! There is no array of objects.
Yet, right after the "new" call, indexer is used, like obj[0], obj[1],
obj[2], ..., objNo. When these objects are instantiated? Also, I have tried
printing messages through contructor, hoping that array-like reference
through the indexer will invoke a constructor for each object in the array,
but it did not. Only once that happened when the object is first (and only
time, it appears) was created.
Any explanation? Is there arereally "n" objects created from the class that
has declared an "indexer"?
Thanks for the help!
Nash,
Toronto