.NET/Link API Version 1.7 USE FRAMES

IMathLink.GetArray Method

Reads an array of the specified type and depth.

Overload List

Reads an array and discards information about the heads at each level.

Array GetArray(Type,int);

Reads an array and records information about the heads at each level.

Array GetArray(Type,int,out string[]);

Remarks

Use this method when you want to read a 2-dimensional or deeper array. You will typically cast the result of this method to the desired array type, as in:

// C#
int[,,] result = (int[,,]) ml.GetArray(typeof(int), 3);
   
// VB
Dim result(,,) as Integer = CType(ml.GetArray(GetType(Integer), 3), GetType(Integer(,,)))
The expression does not need to have head List. It can have any heads, at any depth, and the heads do not have to agree at each depth, meaning that you could read the expression {foo[1, 2], bar[3, 4]} as an int[,].

This method only works for arrays that are rectangular, not jagged. In other words, you can read a Mathematica list like this: {{1,2,3},{4,5,6}} but not like this: {{1,2,3},{4,5}}.

For reading one-dimensional arrays, there are convenience functions for all the simple types, such as GetInt32Array, GetBooleanArray, GetStringArray, and so on. These methods are typed to return the specified type of array, so no casting is required.

See Also

IMathLink Interface | Wolfram.NETLink Namespace