PlausiblyDamp
Administrator
Basic sample class...
Sample code to populate / save list...
Reading it back in...
hope that gets you started.
Code:
Public Class Member
Private _Name As String
Private _Phone As String
Private _Address As String
Public Sub New()
End Sub
Public Sub New(ByVal name As String, ByVal phone As String, ByVal address As String)
_Name = name
_Phone = phone
_Address = address
End Sub
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal value As String)
_Name = value
End Set
End Property
Public Property Phone() As String
Get
Return _Phone
End Get
Set(ByVal value As String)
_Phone = value
End Set
End Property
Public Property Address() As String
Get
Return _Address
End Get
Set(ByVal value As String)
_Address = value
End Set
End Property
End Class
Sample code to populate / save list...
Code:
Dim members As New List(Of Member) for .net 2 use an array or arraylist for .net 1
members.Add(New Member("Jim Bob", "(123) 456-7890", "Not a cowboy"))
members.Add(New Member("John Hancock", "(098) 765-4321", "Sometown"))
members.Add(New Member("etc.", "etc.", "etc."))
Dim xs As New Xml.Serialization.XmlSerializer(GetType(List(Of Member)))
Dim fs As New System.IO.FileStream("c:\test.xml", IO.FileMode.Create, IO.FileAccess.ReadWrite)
xs.Serialize(fs, members)
fs.Close()
Reading it back in...
Code:
Dim xs2 As New Xml.Serialization.XmlSerializer(GetType(List(Of Member)))
Dim fs2 As New System.IO.FileStream("c:\test.xml", IO.FileMode.Open, IO.FileAccess.Read)
Dim m As List(Of Member)
m = DirectCast(xs2.Deserialize(fs2), List(Of Member))
fs2.Close()
hope that gets you started.