lets say I have an array like this:
byte[,] arr = new byte[4,4];
byte[] x = arr[0]; // error here
how come I cannot do this, the error im getting:
Indexer has 2 parameters but is invoked with 1 argument
Thanks Daniel
lets say I have an array like this:
byte[,] arr = new byte[4,4];
byte[] x = arr[0]; // error here
how come I cannot do this, the error im getting:
Indexer has 2 parameters but is invoked with 1 argument
Thanks Daniel
Your arr
array is a two-dimensional array, so imagine a grid. Therefore, you need two indices in order to access any element: row index and column index.
If you're trying to get an entire row, which is what it looks like you're trying to do, then you will need to use staggered arrays as user pm100 said.
// Initialize array size
byte[][] arr = new byte[4][];
for (int i = 0; i < arr.GetLength(0); i++)
arr[i] = new byte[4];
// Grab the first row
byte[] x = arr[0];