Multi-dimensional arrays

A

Amien Crombie

Hi

I have a multi-dimensional array like this:

public double[,] mArray = new double[8,48];

Now I need to add another double[] to the 4th indices:

e.g.

double[] dbx = new dbx[48];

for (int i = 0; i < 48; i++)
{ // I add values to my array }


After this I need to add this array dbx to a predetermined index e.g 4

Something like this : mArray[4, dbx]; ????

Thanks
 
G

Göran Andersson

Amien said:
Hi

I have a multi-dimensional array like this:

public double[,] mArray = new double[8,48];

Now I need to add another double[] to the 4th indices:

e.g.

double[] dbx = new dbx[48];

for (int i = 0; i < 48; i++)
{ // I add values to my array }


After this I need to add this array dbx to a predetermined index e.g 4

Something like this : mArray[4, dbx]; ????

Thanks

You copy the values into the array:

for (int i = 0; i < dbx.Length; i++) mArray[4, i] = dbx;

If you use a jagged array instead of a two dimensional array, you can
just assign the array:

public double[][] mArray = new double[8][]
for (int i = 0; i < mArray.Length; i++) mArray = new double[48];

mArray[4] = dbx;
 
A

Amien Crombie

Göran Andersson said:
Amien said:
Hi

I have a multi-dimensional array like this:

public double[,] mArray = new double[8,48];

Now I need to add another double[] to the 4th indices:

e.g.

double[] dbx = new dbx[48];

for (int i = 0; i < 48; i++)
{ // I add values to my array }


After this I need to add this array dbx to a predetermined index e.g 4

Something like this : mArray[4, dbx]; ????

Thanks

You copy the values into the array:

for (int i = 0; i < dbx.Length; i++) mArray[4, i] = dbx;

If you use a jagged array instead of a two dimensional array, you can
just assign the array:

public double[][] mArray = new double[8][]
for (int i = 0; i < mArray.Length; i++) mArray = new double[48];

mArray[4] = dbx;


Goran, thanks for the help.
The use of a jagged array works perfectly.
Peter, I am getting the 48 double array from somewhere so I'm copying
the array to mArray. Sorry for not being more precise.
The order of my first array is random. I've got 8 ranges per 48 channel
doubles and as I know what ranges I receive, I can easily assign the
second array to the known range.
The jagged array also allows for different array lengths.
Thanks for the help guys.

Amien
Cape Town
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top