Aray and pointer

  • Thread starter Thread starter Le Minh
  • Start date Start date
L

Le Minh

In Visual C++ we use
double **m_domimage[4];
for 3dimension array which has one fix length.

How do we use this method in C#?

thanks
 
Le said:
In Visual C++ we use double **m_domimage[4]; for 3dimension array which
has one fix length.

How do we use this method in C#?


private double[][][] dominage = new double[ 4 ][][];

That being an array of an array of an array of doubles.
With the new operator, you fix the first dimension on 4 in this case.

When using, you will do things like:
dominage[ 0 ] = new double[ 5 ][];
dominage[ 0 ][ 0 ] = new double[ 6 ];
dominage[ 0 ][ 0 ][ 0 ] = Math.PI;

etc.

If you want a fixed 3D matrix, then you would declare as:

private double[ , , ] dom = new double[ 4, 5, 6 ];

This is obviously a 4x5x6 matrix.

Or any combination of the above.
Have fun. :)

David



Note: I used "dominage" as name, instead of "m_dominage". The first is
C# convention (camel case for private data members), the latter C++
convention.
 

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

Back
Top