Is there a way to convert a 2d generic list to a string in unityscript

I have some javascript code I’m trying to convert that takes a two dimensional array and uses a javascript join to turn it into a string then splits the string to turn it into a one dimensional array.

I’m converting this code to run on iphone in pragma strict so I’m using generic .net lists instead of javascript type arrays. Is there an equivalent of the javascript type of join for generic lists or maybe another way to do this.

You can use String.Join to join string arrays into one string. If you have a generic list of strings, then you have to convert it to array before joining:

var list : List.<String> = new List.<String>();
var s = String.Join(",", list.ToArray());

If you want to convert generic list of non-string elements, then you have to cast them to strings first:

var list : List.<int> = new List.<int>();
var stringList = list.Select(function(x) x.ToString());
var s = String.Join(",", stringList.ToArray());

Above examples require System.Collections.Generic and System.Linq namespaces, so you have to import these:

import System.Collections.Generic;
import System.Linq;

UPDATE: after info from comments - you should be able to get flattened list from your variable using

var flattenedArray = list.SelectMany(function(x) x).ToArray();

where list is your generic list.