Share via


XmlRootAttribute.DataType 屬性

定義

取得或設定 XML 根項目的 XSD 資料類型。

public:
 property System::String ^ DataType { System::String ^ get(); void set(System::String ^ value); };
public string DataType { get; set; }
member this.DataType : string with get, set
Public Property DataType As String

屬性值

String

XSD (XML 架構檔) 資料類型。

備註

下表列出 XSD 單一資料型別及其 .NET 對等專案。

針對 XSD base64BinaryhexBinary 資料類型,請使用結構的陣列 Byte ,並視需要將 屬性設定為 「base64Binary」 或 「hexBinary」 套用 XmlRootAttribute DataType 。 針對 XSD timedate 資料類型,請使用 DateTime 型別並套用 XmlRootAttribute ,並將 DataType 設定為 「date」 或 「time」。

針對對應至字串的每個 XSD 類型,請套用 其 XmlRootAttribute DataType 屬性設定為 XSD 型別的 。 不過,這不會變更序列化格式,只會變更成員的架構。

注意

屬性會區分大小寫,因此您必須將其設定為其中一個 XSD 資料類型。

注意

將二進位資料當做 XML 元素傳遞比傳遞為 XML 屬性更有效率。

如需 XML 資料類型的詳細資訊,請參閱名為 XML 架構第 2 部分:資料類型的萬維網聯盟檔。

XSD 資料類型 .NET 資料類型
anyURI String
base64Binary Byte物件的陣列
boolean Boolean
byte SByte
日期 DateTime
dateTime DateTime
decimal Decimal
double Double
ENTITY String
實體 String
FLOAT Single
gDay String
gMonth String
gMonthDay String
gYear String
gYearMonth String
hexBinary Byte物件的陣列
ID String
IDREF String
IDREFS String
int Int32
整數 String
語言 String
long Int64
名稱 String
NCName String
negativeInteger String
NMTOKEN String
NMTOKENS String
normalizedString String
nonNegativeInteger String
nonPositiveInteger String
NOTATION String
positiveInteger String
QName XmlQualifiedName
recurringDate String
duration String
字串 String
short Int16
time DateTime
token String
unsignedByte Byte
unsignedInt UInt32
unsignedLong UInt64
unsignedShort UInt16

適用於