Aded in .NET 1.1
Can be used to serialise .NET types to XML files.
link -

Data is commonly sent and retrieved in an XML format but processing the XML directly is a nightmare
To make this transition easier you can convert from XML to an object.
Converting between XML and custom business objects is known as serialization and there is a namespace dedicated to this.
Was used by ASMX web services

Classes - System.XML.Serialization.XMLSerializer
Lets you convert objects to XML and visa versa.
This class will also automatically create arrays when there are nested elements

converts object to a stream of bytes
to persist the state of an object to a storage medium so an exact copy can be recreated at a later stage
to send an object by value from one app domain to another
can be used to save objects to the clipboard

.NET provides an automate serilization mechanism by using Reflection
When an object is serialized, the name of the class, the assembly and all the data members are written to storage.

Serialize and Deserialize can work with a Stream, XmlWriter/XmlReader or TextWriter/TextReader

Serializing a Class

Public Class MyClass

Private MyField As Boolean
Private m_bMyFlag As Boolean

Public Sub New
   m_bMyFlag = False
End Sub

Public Property MyFlag() As Boolean
      Return m_bFlag
   End Get

   Set(ByVal value As Boolean)
      m_bMyFlag = value
   End Set
End Property

Public Class AnotherClass
End Class

End Class

Renaming Classes

Public class MyClass

Renaming Elements

public string myelement

Renaming Attributes

public boolean myattribute

<newclass newattribute="one"> 

Ignoring Properties

Public string myproperty



© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext