The indexer for List<T>allows you to access elements using properties (Methods), which makes it look like an array. You cannot pass the generated method refas if you wrote:
Interlocked.Increment(ref myList.GetItem.get_Item(0));
. CLR. array[i] , ref.
#:
, , . , ref out.
List<T> ( ):
public T this[int index]
{
get
{
return _items[index];
}
set { _items[index] = value;}
}
IL :
IL:
IL_0014: ldelem.i4
List :
IL_001b: callvirt instance !0 class [mscorlib]System.Collections.Generic.List`1<int32>::get_Item(int32)
, #. .