Home >Backend Development >C#.Net Tutorial >Detailed explanation of serialization and deserialization examples related to contract classes
The contract class refers to the class that inherits: DataContract. Contract classes are often used to transmit data in various services such as WCF and webService.
For any contract class or a class that inherits a contract class, if you want attributes to participate in serialization and deserialization, you need to add a mark to the attribute: DataMember
Such as:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Runtime.Serialization;namespace SinoOcean.Seagull2.Framework.Contracts.Fund { [DataContract]public class SubAccountItemContract {#region 属性/// <summary>/// 账号/// </summary> [DataMember]public string AccountNumber { get; set; }/// <summary>/// 金额/// </summary> [DataMember]public decimal Money { get; set; } } }
The above is the detailed content of Detailed explanation of serialization and deserialization examples related to contract classes. For more information, please follow other related articles on the PHP Chinese website!