0

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; }    

    }
3
  • Do you want to do this for deserialization? Commented Dec 14, 2012 at 18:02
  • @BhushanFirake - I want this to be passed to a javascript object. Commented Dec 14, 2012 at 18:08
  • You want this then: james.newtonking.com/projects/json-net.aspx Commented Dec 14, 2012 at 18:10

1 Answer 1

2

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();
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks,Please see my Edit in the question. Basically I want array which has both string and int

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.