var serverData = serverConnection.connect("login.php", pairs);
RootObject json = JsonConvert.DeserializeObject<RootObject>(await serverData);
foreach (Logined m in json.logined)
{
}
public class Logined
{
public string id { get; set; }
public string firsname { get; set; }
public string lastname { get; set; }
public string email { get; set; }
public string phone { get; set; }
public string profilePic { get; set; }
public string thumbnail { get; set; }
}
public class RootObject
{
public Logined logined { get; set; }
}
它所说的每个错误都不能对getenumerator的公共定义类型的变量进行操作
答案 0 :(得分:0)
您的根对象只包含一个Logined,因此无需枚举。
public class RootObject
{
public Logined logined { get; set; } //not a collection
}
foreach (Logined m in json.logined) //json.logined is a single object (not a collection)
{
}
如果服务器返回Logined集合,则必须更改RootObject定义。
public class RootObject
{
public Logined[] logined { get; set; } //array of Logined
}