Main Content

NET.convertArray

(Not recommended) Convert numeric MATLAB array to .NET array

NET.convertArray is not recommended. MATLAB® automatically converts arrays to .NET types. For information, see Version History.

Description

arrObj = NET.convertArray(V,arrType,[m,n,p,...]) converts a MATLAB array to a .NET array of type arrType. If you do not specify arrType, then MATLAB converts the array according to the MATLAB Primitive Type Conversion Table. See Pass Primitive .NET Types. To convert a MATLAB vector to a two-dimensional .NET array (either 1-by-n or m-by-1), use optional values m,n,p,.... If V is a MATLAB vector and you do not specify the number of dimensions and their sizes, then arrObj is a one-dimensional .NET array.

example

arrObj = NET.convertArray(V,arrType,m,n,p,...) is an alternative syntax for converting an array.

Examples

collapse all

Create a list L of random System.Int32 integers using the System.Collections.Generic.List class, and then sort the results.

% Create array R of random integers
nInt = 5;
R = randi(100,1,nInt);
% Create .NET array A
A = NET.convertArray(R,'System.Int32');
% Put A into L, a generic collections list
L = NET.createGeneric('System.Collections.Generic.List',{'System.Int32'},A.Length);
L.AddRange(A)
% Sort the values in L
L.Sort

Input Arguments

collapse all

MATLAB array, specified as a valid numeric MATLAB type.

.NET array type, specified as a string or a character vector. The name includes a namespace.

Example: 'System.Int32'

Number of elements in each dimension, specified as an array of integers.

Output Arguments

collapse all

Version History

Introduced in R2009a

expand all