lplayer
asked on
How do I create an array (8x8) of BitArrays (16 bits).
I awarded the points as the question was answered, the answer being:
BitArray[,] board = new BitArray[8, 8];
for (int i = 0; i < 8; i++)
{
for (int j = 0; j < 8; j++)
{
board[i, j] = new BitArray(16);
}
}
However, my question evolves.....what if I want the 8x8 Array to contain a Struct, so that each square on the board has an int colour and a 16 bitArray , and an int array [3]
BitArray[,] board = new BitArray[8, 8];
for (int i = 0; i < 8; i++)
{
for (int j = 0; j < 8; j++)
{
board[i, j] = new BitArray(16);
}
}
However, my question evolves.....what if I want the 8x8 Array to contain a Struct, so that each square on the board has an int colour and a 16 bitArray , and an int array [3]
why dont you create an array of structure which meets your requirement
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks CuteBug,
board[3, 3].bitArray[0] = true;
board[2, 2].colour = 1;
board[1, 1].array[2] = 5
For completeness for other lost souls trying to fathom out Structs/arrays, all the above work
board[3, 3].bitArray[0] = true;
board[2, 2].colour = 1;
board[1, 1].array[2] = 5
For completeness for other lost souls trying to fathom out Structs/arrays, all the above work