How do I return a single object with an array and a list?

I have a list and an array that I would like to return, but I'm unsure how to bring the two together. I have deserialized my JSON and created two objects. How do I bring this list and array together in a single object? :

var one = JsonConvert.DeserializeObject<MyData.RootObject>(first);
var two = JsonConvert.DeserializeObject<MyData.RootObject>(second);

List<myData.DataOne> listOne = new List<myData.DataOne>();

foreach (var items in one) 
{
     someDataModel model = new someDataModel();
     model.property = one.rows.f[0].v;
     listOne.Add(model);
}

string[] array = new string[two.rows.Count];

        for (var items = 0; items < two.rows.Count; items++)
        {
            array[items] = two.rows[items].f[0].v;
        }

return null;

Upvotes: 3

Views: 112

Answers (2)

Sarin Vadakkey Thayyil
Sarin Vadakkey Thayyil

Reputation: 954

Create a Tuple with types as List<> and string[].

var tupleObject = new Tuple<List<myData.DataOne>, string[]>(listOne, array);
return tupleObject;

Upvotes: 2

StriplingWarrior
StriplingWarrior

Reputation: 156524

Create a new class to represent the combination of these two pieces of data:

public class MyReturnType 
{
    public List<myData.DataOne> ListOne {get;set;}
    public string[] Array {get;set;}
}

Then return it:

return new MyReturnType {ListOne = listOne, Array = array};

Upvotes: 3

Related Questions