title: how to read an HDF5 multi-dimensional array dataset using HDF5DotNet from C# .net?
body: <p>I need to read a HDF5 dataset that contains a 3 x 3 array, datatype is double.</p>
  
  <p>My Visual Studio 2017 Pro crashes when returning from my code below.</p>
  
  <p>Stepping with debugger, this code reads the 2-dim array from the HDF5; I can read it in the debugger; but function read_double_array crashes when it returns to caller.</p>
  
  <p>2ND CODE ATTEMPT FROM EXAMPLE AT <a href="https://stackoverflow.com/questions/32122092/how-can-i-write-a-large-multidimensional-array-to-an-hdf5-file-in-parts">STACKO </a>…. </p>
  
  <pre><code>    public static double[,]  read_double_array( H5FileId fileId, string dataset_name, int dim1, int dim2 )
  {
      double [,] return_data = new double[ dim1, dim2 ];
      try
      {
          H5Array&lt;double&gt; h5_array = new H5Array&lt;double&gt;( return_data );
          H5DataSetId double_array_dataset  = H5D.open( fileId, dataset_name );
          H5D.read&lt;double&gt;(   double_array_dataset, 
                              new H5DataTypeId(H5T.H5Type.NATIVE_DOUBLE), 
                              h5_array );
          H5D.close(double_array_dataset);
  
      }
      catch( HDFException e )
      {
          Console.WriteLine( e.Message );
          int aa=0;
      }
      return return_data;
  }
  </code></pre>
  
  <p>MY CODE 1ST ATTEMPT, WHICH CRASHED ……………………</p>
  
  <pre><code>public static double[,]  read_double_array( H5FileId fileId, string dataset_name, int dim1, int dim2 )
  {
          double [,] return_data = new double[ dim1, dim2 ];
      try
      {
          H5DataSetId dataSetId  = H5D.open( fileId, dataset_name );
          H5D.read(   dataSetId, 
                      new H5DataTypeId( H5T.H5Type.NATIVE_DOUBLE ),
                      new H5Array&lt;double&gt;( return_data ) );
      }
      catch( HDFException e )
      {
          Console.WriteLine( e.Message );
          int aa=0;
      }
      return return_data;  &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;   H A N G S   H E R E
  }
  </code></pre>