Mystery behind System.Array

后端 未结 1 1734
隐瞒了意图╮
隐瞒了意图╮ 2021-01-04 03:53

We know System.Array is a abstract class and whatever DataType[] we use runtime creates some concrete implementation for us somehow (vague though).

1条回答
  •  孤城傲影
    2021-01-04 04:22

    You're not seeing any call to that method, because you're invoking it yourself, as weird as that may sound. SZArrayHelper is a CLR wrapper around an array, that implements the IList interface, kinda like the adapter pattern.

    From this perspective, it makes sense that collection.Clear invokes SZArrayHelper.Clear directly.

    Hans Passant explains this very well here: https://stackoverflow.com/a/11164210/857807

    0 讨论(0)
提交回复
热议问题