Hello everyone:

 

I was hoping someone would be able to help me out with some details about indexers and collections and how they are used in mono.

 

I was trying to implement some functionality to the ArrayList class in System.Collections through the use of the ArrayLists indexers.

 

I had thought that if you wrote the code snippet the ArrayList’s indexer function would be invoked 100 times because of the second for loop:

 

/////////////// begin

ArrayList myAL;

myAL = new ArrayList();

 

for(int i=0; i<100; i++)

myAL.Add(i); //(add a bunch of numbers to the array list)

 

int sum = 0;

for(int i=0; i<100; i++)

            sum = sum + (int)myAL[i];

/////////////// end

 

 

However, I am finding that the indexer is not called at all and from disassembling the executable, the following instructions are occurring where I would have thought the indexer would have been called:

.

.          

IL_0099:  callvirt instance object class [mscorlib]'System.Collections.ArrayList'::'get_Item'(int32)

IL_009e:  unbox [mscorlib]System.Int32

.

.

 

Normally, this wouldn’t be a problem for me.  However, I cannot find this “get_Item” function anywhere in the mcs or mono source code.  There is also a corresponding “set_Item” function that is called as well, but again, I cannot find it in the source code.

 

Is there a situation where the ArrayList Indexer will be called?  And do the get_Item and set_Item functions exist somewhere in the source code?

 

Basically, all I want to be able to do is monitor accesses to an ArrayList through some predefined interface, whether the indexer or these get_Item and set_Item functions.  Any information about any of these things would be much appreciated.

 

Thank you for your time,

 

Andrew P. Wilson

Electrical and Computer Engineering Department

University of Toronto

 

Reply via email to