本文整理匯總了VB.NET中System.Xml.Serialization.XmlArrayItemAttribute.Type屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET XmlArrayItemAttribute.Type屬性的具體用法?VB.NET XmlArrayItemAttribute.Type怎麽用?VB.NET XmlArrayItemAttribute.Type使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Xml.Serialization.XmlArrayItemAttribute
的用法示例。
在下文中一共展示了XmlArrayItemAttribute.Type屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Group
' 導入命名空間
Imports System.IO
Imports System.Xml.Serialization
Public Class Group
' The Type property instructs the XmlSerializer to accept both
' the Person and Manager types in the array.
<XmlArrayItem(Type := GetType(Manager)), _
XmlArrayItem(Type := GetType(Person))> _
Public Staff() As Person
End Class
Public Class Person
Public Name As String
End Class
Public Class Manager
Inherits Person
Public Rank As Integer
End Class
Public Class Run
Public Shared Sub Main()
Dim test As New Run()
test.SerializeOrder("TypeEx.xml")
End Sub
Public Sub SerializeOrder(filename As String)
' Creates an XmlSerializer.
Dim xSer As New XmlSerializer(GetType(Group))
' Creates the Group object, and two array items.
Dim myGroup As New Group()
Dim p1 As New Person()
p1.Name = "Jacki"
Dim p2 As New Manager()
p2.Name = "Megan"
p2.Rank = 2
Dim myStaff() As Person = {p1, p2}
myGroup.Staff = myStaff
' Serializes the object, and closes the StreamWriter.
Dim writer As New StreamWriter(filename)
xSer.Serialize(writer, myGroup)
End Sub
End Class