Gokul
Gokul

Reputation: 1371

Create An Array of Array in c#

Hi How to create an Array of Arrays like

  EDIT: [[1,"aaaaaa",1],[2,"bbbbbbb",2],[3,"ccccccc",3]]

from a list

IList<TestList>

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

    }

Upvotes: 0

Views: 110

Answers (1)

Khan
Khan

Reputation: 18162

If I understand what you're looking for, this should do the trick:

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();

Upvotes: 2

Related Questions