在c#中创建一个数组数组

时间:2012-12-14 17:59:57

标签: arrays c#-4.0 collections

您好如何创建像

这样的数组数组
  EDIT: [[1,"aaaaaa",1],[2,"bbbbbbb",2],[3,"ccccccc",3]]

从列表中

IList<TestList>

public class TestList
    {
        public int x{ get; set; }
        public string Name { get; set; }
        public int y{ get; set; }    

    }

1 个答案:

答案 0 :(得分:2)

如果我理解你在寻找什么,这应该可以解决问题:

IList<TestList> testList;

public class TestList
{
    public int x{ get; set; }
    public string Name { get; set; }
    public int y{ get; set; }
}

var newList = testList.Select(t => new object[] { t.x, t.Name, t.y});
var myArrayOfArrays = newList.ToArray();