Serialize Object to XML Stream and output to screen : Serialize Object « File Directory « VB.Net






Serialize Object to XML Stream and output to screen

  
Imports System
Imports System.Xml
Imports System.Xml.Serialization

 
Public Class MainClass

    Shared Sub Main(  )
       Dim serialize As XmlSerializer = _
              New XmlSerializer(GetType(Order))
       Dim MyMovieOrder As Order = _
              New Order("Name", 101, 10)
       serialize.Serialize(Console.Out, MyMovieOrder)
       Console.Out.WriteLine()

    End Sub
  
End Class

Public Class Order
    Public name As String
    Public id As Integer
    Public quantity As Integer

    Public Sub New()
    End Sub

    Public Sub New(ByVal name As String, _
                   ByVal id As Integer, _
                   ByVal quantity As Integer)
        Me.name = name
        Me.id = id
        Me.quantity = quantity
    End Sub
End Class
  
           
         
    
  








Related examples in the same category

1.Serialize Data to Binary and XML at the same time
2.Save Serializable Object to binary file: create a sequential-access file
3.Serializable Person Object
4.Serialize to Xml
5.Simple Serializable Person Object
6.MarshalByRefObject access objects across application domain