Question

            public const T = true;
            public static bool[,] MassMediumHorizontal = new bool[,]
            { 
            {T,T,T,T,T,T},
            {T,T,T,T,T,T},
            {T,T,T,T,T,T},
            {T,T,T,T,T,T},
            {T,T,T,T,T,T},
            {T,T,T,T,T,T},
            {T,T,T,T,T,T},
            {T,T,T,T,T,T},
            {T,T,T,T,T,T},
            {T,T,T,T,T,T},
            {T,T,T,T,T,T},
            {T,T,T,T,T,T}
            };

As you all can see, this array has a width of 6 and a height of 12.

When I compile it, the width and height is flipped.

If I place a break point while debugging (visual studio feature) then hover over the variable's name, it tells me the size of the array, and it says 12x6 (width x height).


Of course, If I want to get the opposite of this, then I would just make the original array 12x6 and end up with 6x12 after compiling.

But why does this happen in the first place? (I don't rotate it what so ever after compiling)

Was it helpful?

Solution

Thinking about arrays as width and height is confusing the matter. The measurements start from the outer-most dimension.

Your outer dimension is 12, and the inner is 6. Hence 12 x 6. It's just the way it works.

OTHER TIPS

Arrays don't really have a concept of 'width' and 'height', the dimensions are arbitrary.

It just so happens that the length of the array in first dimension is 12 and the length of the array in the second dimension is 6, so it's a 12x6 array. The fact that you and I conventionally think of the first dimension as 'width' and the second as 'height' is not relevant to the compiler.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top