在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
//父类可序列化 [Serializable] [DataContract] public class QueryParameters { [DataMember] public string ApplicantName { get; set; } [DataMember] public string IdentifyNumber { get; set; } } //继承类也可序列化 [Serializable] [DataContract] public class AntiFraudRequestParamters : QueryParameters { [DataMember] public string QueryEmployee { get; set; } [DataMember] public string QueryReason { get; set; } [DataMember] public string QueryEndDate { get; set; } } var bhParas = new AntiFraudRequestParamters (); string entity = JsonConvert.SerializeObject(bhParas, Formatting.None); //NewTonSoft.Json序列化得到结果: { "ApplicantName": null, "IdentifyNumber": null, "QueryEmployee": null, "QueryReason": null, "QueryEndDate": null } //继承类不加可序列化 public class AntiFraudRequestParamters : QueryParameters { public string QueryEmployee { get; set; } public string QueryReason { get; set; } public string QueryEndDate { get; set; } } var bhParas = new AntiFraudRequestParamters (); string entity = JsonConvert.SerializeObject(bhParas, Formatting.None); //NewTonSoft.Json序列化得到结果: { "ApplicantName": null, "IdentifyNumber": null } //结果没有得到继承类加的三个属性
|
请发表评论