Imports System.Runtime.Serialization.Formatters.Binary Imports System.IO Imports System.Runtime.Serialization Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim lista As New List(Of Integer) For i As Integer = 0 To 9 lista.Add(i + 1) Next Dim bin As New BinaryFormatter Dim mStream As New MemoryStream bin.Serialize(mStream, lista) lista.Clear() ' Para comprobar que se está serializando mStream.Close() Try Dim ms As Stream = New MemoryStream(mStream.ToArray) Dim myList As List(Of Integer) = DirectCast(bin.Deserialize(ms), List(Of Integer)) For i As Integer = 0 To 9 MessageBox.Show(myList(i)) Next ms.Close() Catch ex As Exception MessageBox.Show(ex.ToString) End Try End Sub
lunes, 5 de junio de 2017
Serialización de una lista de enteros
Etiquetas:
BinaryFormatter,
Deserialize,
DirectCast,
MemoryStream,
serializacion,
Serialize
Suscribirse a:
Comentarios de la entrada (Atom)
No hay comentarios.:
Publicar un comentario