C
C#2y ago
fakie

❔ why is there a comma in the [] when working in a multidimensional array

im fairly advanced with c# but had no use to use multidimensional arrays for what im working on so i dont know why there is a comma like this [ , ]
8 Replies
Thinker
Thinker2y ago
The comma specifies the dimensions of the array [] is one dimension, [,] is two dimensions, [,,] is three dimensions, etc. The dimension is part of the type itself
fakie
fakieOP2y ago
alright tanks thanks
mtreit
mtreit2y ago
In the rare cases I've ever needed something like a multi-dimensional array, I actually find jagged arrays (arrays of arrays) much more intuitive. Plus, they are (very counterintuitively) faster!
Thinker
Thinker2y ago
And they also have way more standard library support.
mtreit
mtreit2y ago
What's an example?
Thinker
Thinker2y ago
Name one method in the BCL which uses 2d arrays when
fakie
fakieOP2y ago
agreed
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server