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


i have list , array return, i'm unsure how bring 2 together. have deserialized json , created 2 objects. how bring list , array in single object? :

var 1 = jsonconvert.deserializeobject<mydata.rootobject>(first); var 2 = 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];          (var items = 0; items < two.rows.count; items++)         {             array[items] = two.rows[items].f[0].v;         }  return null; 

create new class represent combination of these 2 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}; 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -