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; }
}
}
}