https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/data-member-order

In some applications, it is useful to know the order in which data from the various data members is sent or is expected to be received (such as the order in which data appears in the serialized XML).

Sometimes it may be necessary to change this order.

This topic explains the ordering rules.

Basic Rules

The basic rules for data ordering include:

  • If a data contract type is a part of an inheritance hierarchy, data members of its base types are always first in the order.

  • Next in order are the current type’s data members that do not have the Order property of the DataMemberAttribute attribute set, in alphabetical order.

  • Next are any data members that have the Order property of the DataMemberAttribute attribute set. These are ordered by the value of the Order property first and then alphabetically if there is more than one member of a certain Order value. Order values may be skipped.

Alphabetical order is established by calling the CompareOrdinal method.

用途

1.序列化的时候,指定顺序,和xml匹配

2.序列化的时候,属性之间有依赖关系,比如A属性在set的时候,有自己的logic,去设置了B属性。

这种情况下,必须先序列化A属性,再序列化B属性。

when a property has a logic for set or get,then apply data member attribute to field

Data Member Order的更多相关文章

  1. C++ Data Member内存布局

    如果一个类只定义了类名,没定义任何方法和字段,如class A{};那么class A的每个实例占用1个字节的内存,编译器会会在这个其实例中安插一个char,以保证每个A实例在内存中有唯一的地址,如A ...

  2. Effective C# 学习笔记(原则一:始终能的使用属性(property),而不是可直接访问的Data Member)

    原则一:始终能的使用属性(property),而不是可直接访问的Data Member    Always use properties instead of accessible data memb ...

  3. 3.1 Data Member的绑定

       文章开始提出了一段示例代码,并讨论了返回哪个x的问题.然后 a)   给出了我们普遍认为正确的回答,并肯定了这个想法: b)   提醒大家,这在以前的编译器实现中,并非正确. 在早期的实现中,首 ...

  4. warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]

    struct test{int a=1111111; }test; vincentdeMacBook-Air:datasturte vincent$ g++ struct.cpp -o structp ...

  5. 始终使用属性(Property),而不是字段(Data Member)

    1.始终使用属性(Property),而不是字段(Data Member) C# 属性已经晋升为一等公民,如果你的类中还有public的字段,Stop.访问属性和字段的方式是一样的,但是属性是用方法( ...

  6. 数据框排序 data.frame order

    # sorting examples using the mtcars datasetattach(mtcars) # sort by mpgnewdata <- mtcars[order(mp ...

  7. TCP carries HTTP data in order, and without corruption

    wTCP/IP承载几乎所有的HTTP通信. HTTP The Definitive Guide

  8. Learning WCF Chapter2 Data Contracts

    A data contract describes how CLR types map to XSD schema definitions. Data contracts are the prefer ...

  9. R语言 data.frame 大全

    A data frame is used for storing data tables. It is a list of vectors of equal length. For example, ...

随机推荐

  1. ASP.NET-DropDownListFor绑定model数据

    在ASP.NET中,DropDownListFor绑定model数据比用html的select方便太多了,配合listmode这种模型集合就可以在controller里面直接foreach循环处理li ...

  2. POJ-1785-Binary Search Heap Construction(笛卡尔树)

    Description Read the statement of problem G for the definitions concerning trees. In the following w ...

  3. 【c语言】输入一个递增排序的数组的一个旋转,输出旋转数组中的最小元素

    //旋转数组的最小数字 //题目:把一个数组最開始的若干个元素搬到数组的末尾.我们称之为数组的旋转. //输入一个递增排序的数组的一个旋转.输出旋转数组中的最小元素. //比如:数组{3.4,5,1, ...

  4. hdu 4628 Pieces(状态压缩+记忆化搜索)

    Pieces Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total S ...

  5. 今天犯的一个错误,导致method GET must not have a request body

    事件经过: 1.在本地机器运行完全正常的程序,手动人工发包到测试环境上,后台日志频频报method GET must not have a request body. 2.使用postman发送pos ...

  6. 【转载】犀利的 oracle 注入技术

    介绍一个在web上通过oracle注入直接取得主机cmdshell的方法. 以下的演示都是在web上的sql plus执行的,在web注入时 把select SYS.DBMS_EXPORT_EXTEN ...

  7. 理解 this.initialize.apply ( this, arguments )定义对象的一种方式

    var Class = { create:function() { return function() { this.initialize.apply(this, arguments); }; } } ...

  8. 获取新浪微博的Access_token

    最近想爬取新浪微博的评论,百度了一下,有个新浪开放平台提供了这个API 于是按照它的说明,去获取Access_token: 1.点击微链接 2.立即创建微链接 3.选择网页应用 4.填写信息后提交 5 ...

  9. frameset宽屏居中写法

    在写frameset的时候发现页面较小的时候不能在屏幕上居中,记录一下frameset页面居中的写法 <frameset cols="*,1280,*" frameborde ...

  10. gcd的queue与group

    queue相当于事件处理机制里的事件池:只是任务池: 线程作为事件处理的实施者,由线程池从任务池中获取任务进行调度派发: group相当与工作组,按照任务的相关性对任务进行组织.