C# Indexer creation and usage syntax is just a shorthand form., like what we have for properties.
I recommend you to read the common language runtime spec, to understand what the different compilers must do when transforming such constructs.
Best regards,
Rafael Teixeira Brazilian Polymath Mono Hacker since 16 Jul 2001 MonoBrasil Founding Member - Membro Fundador do MonoBrasil English Blog: http://monoblog.blogspot.com/ Brazilian Portuguese Blog: http://monoblog.weblogger.terra.com.br/
From: "Andrew P. Wilson" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Subject: [Mono-list] System.Collections intricacies Date: Thu, 29 Jan 2004 14:36:35 -0500
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
_________________________________________________________________
MSN Messenger: instale grátis e converse com seus amigos. http://messenger.msn.com.br
_______________________________________________ Mono-list maillist - [EMAIL PROTECTED] http://lists.ximian.com/mailman/listinfo/mono-list