XmlArrayItemAttribute.Namespace 屬性

定義

取得或設定產生的 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 ref class Transportation
{
public:

   // Sets the Namespace property.

   [XmlArrayItem(Car::typeid,Namespace="http://www.cpandl.com")]
   array<Vehicle^>^MyVehicles;
};
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 符合 XML 中的World Wide Web Consortium 規格命名空間。

若要建立命名空間以用於 XML 檔和相關聯的前置詞,您必須建立 XmlSerializerNamespaces 包含所有前置詞和命名空間組的 。 針對每個 XmlArrayAttribute 設定的命名空間必須包含在 中 XmlSerializerNamespacesXmlSerializer產生檔時,它會正確為每個陣列專案的專案名稱加上前置詞。

適用於