System.Runtime.Serialization.InvalidDataContractException was unhandled by user code
HResult=-2146233088
Message=Type 'xxx.Cost+RootObject' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. Alternatively, you can ensure that the type is public and has a parameterless constructor - all public members of the type will then be serialized, and no attributes will be required.
Source=System.Runtime.Serialization
InnerException:
我看到另一个帖子,有些人建议添加数据合同和数据成员。你能帮我把数据成员和数据合同放在哪里吗?我还是不明白。
这是我的课程代码:
namespace xxx
{
class Cost
{
public class Title
{
public string from { get; set; }
public string to { get; set; }
public string from_zip { get; set; }
public string to_zip { get; set; }
public string from_suburb { get; set; }
public string to_suburb { get; set; }
}
public class Content
{
public string company { get; set; }
public string package { get; set; }
public string rate { get; set; }
public string rate_second { get; set; }
public string est_time { get; set; }
public string inclusion { get; set; }
public string exclusion { get; set; }
public string last_update { get; set; }
}
public class RootObject
{
public Title title { get; set; }
public List<Content> content { get; set; }
}
}
}