Option Explicit
Option Strict
Imports System
Imports System.IO
Imports System.Xml
Imports System.Xml.Serialization
Public Class MyClass1
<XmlArrayAttribute("MyStrings")> Public MyStringArray() As String
<XmlArrayAttribute(ElementName := "MyIntegers")>Public MyIntegerArray() As Integer
End Class
Public Class Run
Public Shared Sub Main()
Dim s As New XmlSerializer(GetType(MyClass1))
Dim myWriter As New StreamWriter("yourName.xml")
Dim class1 As New MyClass1()
Dim myStrings() As String = {"Hello", "World", "!"}
class1.MyStringArray = myStrings
Dim myIntegers() As Integer = {1, 2, 3}
class1.MyIntegerArray = myIntegers
s.Serialize(myWriter, class1)
myWriter.Close()
End Sub
End Class
|