本文整理匯總了VB.NET中System.Xml.Serialization.XmlSerializer.FromTypes方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET XmlSerializer.FromTypes方法的具體用法?VB.NET XmlSerializer.FromTypes怎麽用?VB.NET XmlSerializer.FromTypes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Xml.Serialization.XmlSerializer
的用法示例。
在下文中一共展示了XmlSerializer.FromTypes方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Instrument
' 導入命名空間
Imports System.IO
Imports System.Xml.Serialization
' Three classes are included here. Each one will
' be used to create three XmlSerializer objects.
Public Class Instrument
Public InstrumentName As String
End Class
Public Class Player
Public PlayerName As String
End Class
Public Class Piece
Public PieceName As String
End Class
Public Class Test
Public Shared Sub Main()
Dim t As New Test()
t.GetSerializers()
End Sub
Public Sub GetSerializers()
' Create an array of types.
Dim types(3) As Type
types(0) = GetType(Instrument)
types(1) = GetType(Player)
types(2) = GetType(Piece)
' Create an array for XmlSerializer objects.
Dim serializers(3) As XmlSerializer
serializers = XmlSerializer.FromTypes(types)
' Create one Instrument and serialize it.
Dim i As New Instrument()
i.InstrumentName = "Piano"
' Create a TextWriter to write with.
Dim writer As New StreamWriter("Inst.xml")
serializers(0).Serialize(writer, i)
writer.Close()
End Sub
End Class