What's better in regards to performance? type[,] or type[][]?

前端 未结 4 796
野的像风
野的像风 2021-01-18 23:27

Is it more performant to have a bidimensional array (type[,]) or an array of arrays (type[][]) in C#?

Particularly for initial allocation a

4条回答
  •  無奈伤痛
    2021-01-19 00:15

    type[,] will work faster. Not only because of less offset calculations. Mainly because of less constraint checking, less memory allocation and greater localization in memory. type[][] is not a single object -- it's 1 + N objects that must be allocated and can be away from each other.

提交回复
热议问题