XmlArrayItemAttribute.Namespace 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定產生的 XML 元素的命名空間。
public:
property System::String ^ Namespace { System::String ^ get(); void set(System::String ^ value); };
public string Namespace { get; set; }
public string? Namespace { get; set; }
member this.Namespace : string with get, set
Public Property Namespace As String
屬性值
產生的 XML 元素的命名空間。
範例
以下範例應用 並 XmlArrayItemAttribute 設定屬性 Namespace 。
public class Transportation
{
// Sets the Namespace property.
[XmlArrayItem(typeof(Car), Namespace = "http://www.cpandl.com")]
public Vehicle[] MyVehicles;
}
Public Class Transportation
' Sets the Namespace property.
<XmlArrayItem(GetType(Car), Namespace := "http://www.cpandl.com")> _
Public MyVehicles() As Vehicle
End Class
備註
此 Namespace 屬性符合萬維網聯盟(WWC)在 XML 中規範的命名空間。
要建立用於 XML 文件及相關前綴的命名空間,必須建立包含所有前綴與命名空間對的 。XmlSerializerNamespaces 你為每個 XmlArrayAttribute 設定的命名空間必須包含在 XmlSerializerNamespaces。 當 產生 XmlSerializer 文件時,會正確地為每個陣列項目加上元素名稱。