Public Class MyCustomType
Private _number As Integer
Private _text As String
Public Property Number() As Integer
Get
Return _number
End Get
Set(ByVal value As Integer)
_number = value
End Set
End Property
Public Property Text() As String
Get
Return _text
End Get
Set(ByVal value As String)
_text = value
End Set
End Property
Public Sub Save(ByVal path As String)
Dim serialiser As New XmlSerializer(Me.GetType())
Using file As New FileStream(path, FileMode.Create)
serialiser.Serialize(file, Me)
End Using
End Sub
Public Shared Function Load(ByVal path As String) As MyCustomType
Dim deserialiser As New XmlSerializer(GetType(MyCustomType))
Using file As New FileStream(path, FileMode.Open)
Return DirectCast(deserialiser.Deserialize(file), MyCustomType)
End Using
End Function
End Class