0

In c++ is possible to get a slice of multidimensional array, like

  double parallelopipedPts[8][3];
  parallelopipedPts[0];
  parallelopipedPts[1];
  ...
  parallelopipedPts[7];

In c# I am trying to emulate this and tried

  double[][] parallelopipedPts = new double[8][];
  parallelopipedPts[0];
  parallelopipedPts[1];
  ...
  parallelopipedPts[7];

However I am getting memory access issues

How to solve this?

edgarmtze
  • 24,683
  • 80
  • 235
  • 386

1 Answers1

1

In your C# code, you've created an array of 8 'double arrays'.

The double arrays in that array-of-8 have not yet been assigned, so they are null.

You can populate it with arrays-of-3-doubles (for example) like this:

for (int i = 0; i < parallelopipedPts.Length; i++)
{
    parallelopipedPts[i] = new double[3];
}

Then you can safely use your sub-arrays.

Baldrick
  • 11,712
  • 2
  • 31
  • 35