I currently try to convert a .mat-file to XML. For this task, I have to use a library, which gives me a dynamic object back. I know the structure of the .mat-file, so I can get the data out of it. I store this data in an Object. One of the values of the .mat file is of the MATLAB-type <1701x256 double>. I thought this would be double[][]. But when I try to assign the value, I get:
Unbehandelte Ausnahme: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Der
double[*,*]-Typ kann nicht in double[][] konvertiert werden.
bei CallSite.Target(Closure , CallSite , Object )
bei System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site,T0 arg0)
bei CameraParser.Program.Main(String[] args) in c:\myProject\Program.cs:Zeile 44.
What is double[*,*] for a type? Of which type should the attribute of the object to which I assign the value to, be?
I tried
double[][] myAttribute;
and
double[] myAttribute;
and
double** myAttribute;
The last one gave
Error 6 Pointers and fixed size buffers may only be used in an unsafe context
The
*in the type name indicates that you got a non-conforming array type back. Common with COM servers in particular, they tend to use 1 as the lower bound. You cannot cast such an array to a C# array type, it only supports arrays with a lower bound of 0. But you can cast it toArray.Use the Array methods to access the array. Like Array.GetLowerBound() tells you where to start indexing, GetUpperBound() to find out where to stop. Read an array element with Array.GetValue(). You’ll need the overload that takes int[] since this is a two-dimensional array and not a jagged array.