<Datetimeserialization&gt > 元素<dateTimeSerialization> Element

确定 DateTime 对象的序列化模式。Determines the serialization mode of DateTime objects.

<configuration><configuration>
<dateTimeSerialization><dateTimeSerialization>

语法Syntax

<dateTimeSerialization  
    mode = "Roundtrip|Local"  
/>  

特性和元素Attributes and Elements

下列各节描述了特性、子元素和父元素。The following sections describe attributes, child elements, and parent elements.

特性Attributes

特性Attributes 描述Description
mode 可选。Optional. 指定序列化模式。Specifies the serialization mode. 设置为 DateTimeSerializationSection.DateTimeSerializationMode 值之一。Set to one of the DateTimeSerializationSection.DateTimeSerializationMode values. 默认值为 RoundTrip。The default is RoundTrip.

子元素Child Elements

无。None.

父元素Parent Elements

元素Element 描述Description
system.xml.serializationsystem.xml.serialization 用于控制 XML 序列化的顶级元素。The top-level element for controlling XML serialization.

备注Remarks

在 .NET Framework 1.0、1.1、2.0 以及更高版本中,将此属性设置为 Local 时,DateTime 对象始终设置为本地时间格式。In versions 1.0, 1.1, 2.0 and later versions of the .NET Framework, when this property is set to Local, DateTime objects are always formatted as the local time. 即,序列化的数据中总是包含本地时区信息。That is, local time zone information is always included with the serialized data. 将此属性设置为 Local 可确保与较早版本的 .NET Framework 兼容。Set this property to Local to ensure compatibility with older versions of the .NET Framework.

在 .NET Framework 2.0 及更高版本中,将此属性设置为 Roundtrip 时,系统会检查 DateTime 对象以确定这些对象位于本地时区、UTC 时区还是未指定的时区中。In version 2.0 and later versions of the .NET Framework that have this property set to Roundtrip, DateTime objects are examined to determine whether they are in the local, UTC, or an unspecified time zone. 随后会序列化 DateTime 对象并保留该信息。The DateTime objects are then serialized in such a way that this information is preserved. 这是默认行为,建议为所有不与 Framework 的较早版本通信的新应用程序使用此行为。This is the default behavior and is the recommended behavior for all new applications that do not communicate with older versions of the framework.

请参阅See also