我知道,例如List<T>
索引器类似于属性。这是从msdn上摘取的:
索引器允许类或结构的实例被索引,就像数组一样。索引器类似于属性,除了它们的访问器需要参数。
但我不明白为什么会发生以下情况:
int[] myArray = new int[0];
List<int> myList = new List<int>();
Interlocked.Increment(ref myArray[0]); // fine
Interlocked.Increment(ref myList[0]); //CS0206 A property or indexer may not be passed as an out or ref parameter
他们不应该以相同的方式工作吗?