I have two classes. First class is "StoreList":
class StoreList
{
public string Code { get; set; }
public string Name { get; set; }
public int StoreId { get; set; }
}
Second is DataList:
class DataList
{
public List<StoreList> StoreListData { get; set; } //I don't know if this is correct
}
So I can use in code like this:
var liststoreIds = client.storeList(sessionId); //here I get data from API, all ok
var storeList = new DataList();
foreach (var stores in liststoreIds)
{
storeList.StoreListData.Add(new StoreList
{
Code = stores.code,
Name = stores.name,
StoreId = stores.store_id
});
}
In code I get error: "Object reference not set to an instance of an object." Where is a problem?