siki
siki

Reputation: 9457

Convert list to Array2D

I'm trying to convert a single list to a multi-dimensional Array2D. Basically go from [1; 2; 3] to [[1; 2; 3]]. I can't just use List.toArray as I'm using an API function which takes an int[,] as one of its inputs.

What's the best way to do this?

Upvotes: 4

Views: 399

Answers (1)

Daniel
Daniel

Reputation: 47904

Just nest the list within another list:

array2D [[1; 2; 3]]

> val it : int [,] = [[1; 2; 3]]

Upvotes: 6

Related Questions