XmlTypeAttribute.TypeName 屬性

定義

取得或設定 XML 型別的名稱。

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

屬性值

String

XML 型別的名稱。

範例

下列範例會將 XmlTypeAttribute 套用至 PersonJob 類別。 如果您編譯 類別並將產生的可執行檔傳遞至 XML 架構定義工具,架構會顯示在 [輸出] 區段中。

ref class Person;
ref class Job;
ref class Group
{
public:
   array<Person^>^Staff;
};


[XmlType(TypeName="Employee",
Namespace="http://www.cpandl.com")]
public ref class Person
{
public:
   String^ PersonName;
   Job^ Position;
};


[XmlType(TypeName="Occupation",
Namespace="http://www.cohowinery.com")]
public ref class Job
{
public:
   String^ JobName;
};
public class Group {
   public Person[]Staff;
}

[XmlType(TypeName = "Employee",
         Namespace = "http://www.cpandl.com")]
public class Person {
   public string PersonName;
   public Job Position;
}

[XmlType(TypeName = "Occupation",
         Namespace = "http://www.cohowinery.com")]
public class Job {
   public string JobName;
}
Public Class Group
    Public Staff() As Person
End Class

<XmlType(TypeName := "Employee", _
 Namespace := "http://www.cpandl.com")> _
Public Class Person
    Public PersonName As String
    Public Position As Job
End Class


<XmlType(TypeName := "Occupation", _
 Namespace := "http://www.cohowinery.com")> _
Public Class Job
    Public JobName As String
End Class

備註

XmlTypeAttribute將 套用至 類別,以指定 XML 類型的命名空間、XML 類型名稱,以及是否要在 XML 架構檔中包含類型。 若要查看設定 類別屬性 XmlTypeAttribute 的結果,請將應用程式編譯為可執行檔或 DLL,並將產生的檔案傳遞至 XML 架構定義工具 (Xsd.exe) 。 此工具會寫入架構,包括型別定義。

適用於