lunes 22 de noviembre de 2010

Serialización .NET

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim p = New Prueba() With {.Nombre = "Ismael", .Apellidos = "Zori"}
Dim s = New System.Xml.Serialization.XmlSerializer(GetType(Prueba))
Dim sw = New System.IO.StringWriter()
s.Serialize(sw, p)

MessageBox.Show(sw.ToString())
End Sub
End Class


_
Public Class Prueba
Private m_Nombre As String
Public Property Nombre() As String
Get
Return m_Nombre
End Get

Set(ByVal value As String)
m_Nombre = value
End Set
End Property

Private m_Apellidos As String
Public Property Apellidos() As String
Get
Return m_Apellidos
End Get
Set(ByVal value As String)
m_Apellidos = value
End Set
End Property
End Class