Reputation: 5424
I don't understand how I fix this issue. I have two foreach
loops:
foreach (deviceDetailsModel.Detail d in ddm.device.details)
{
foreach (deviceDetailsModel.Entry e in d)
{
//TODO
}
}
on the 2nd for loop I get the does not contain a public definition for 'GetEnumerator'
error. What am I doing wrong?
This is the class:
public class deviceDetailsModel
{
public int totalCount { get; set; }
public string messages { get; set; }
public Device device { get; set; }
public class Entry
{
public string key { get; set; }
public object value { get; set; }
}
public class Detail
{
public List<Entry> entry { get; set; }
}
public class Device
{
public string @id { get; set; }
public string uuid { get; set; }
public string principal { get; set; }
public int blockReason { get; set; }
public int clientId { get; set; }
public string comment { get; set; }
public int compliance { get; set; }
public int countryCode { get; set; }
public int countryId { get; set; }
public string countryName { get; set; }
public string createdAt { get; set; }
public string currentPhoneNumber { get; set; }
public List<Detail> details { get; set; }
}
}
Upvotes: 0
Views: 2327
Reputation: 126052
I think you meant:
deviceDetailsModel.Entry e in d.entry
instead.
You're getting the error because d
(presumably an instance of the Detail
class) doesn't implement IEnumerable
. You probably wanted to enumerate over the entry
property instead.
Upvotes: 9