Home >Backend Development >C#.Net Tutorial >Detailed explanation of serialization and deserialization examples related to contract classes

Detailed explanation of serialization and deserialization examples related to contract classes

零下一度
零下一度Original
2017-06-23 16:23:561508browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn