ToArray() is a method that is valid only for the MWNumericArray, MWLogicalArray, and MWCharArray types. An element of an MWArray object must be cast to one of these types first before a ToArray() may be issued.
Use the CTYPE Visual Basic function to cast each element of the MWArray array into an MWNumericArray, MWLogicalArray, or MWCharArray, and then call ToArray() on the result. For example, if 'foo' is the MWArray object that contains the various output arguments, the following statement converts the first output argument into a native .NET Double array by way of the MWNumericArray type:
Dim nativeArray(,) As Double = CType(foo(1), MWNumericArray).ToArray(MWArrayComponent.Real)
Refer to the MATLAB Builder NE MWArray Class Library Reference for more details:
Best Answer