This is a mirror of official site: http://jasper-net.blogspot.com/

Serialization vs. Marshaling

| Sunday, June 6, 2010
Are you somewhat confused between Serialization and Marshaling? This writing would break this confusion up, it would give you a basic understanding of the process of Serialization and the process of Marshaling, and how you can get the most out of each.

Serialization
Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file, a memory buffer, or transmitted across a network connection to be “resurrected” later in the same or another computer environment. And this sequence of bits can be of any format the user chooses; however, they are usually formed as XML or binary.

Serialization comes in many forms in .NET Framework, it can be observed in ADO.NET, Web services, WCF services, Remoting, and others.

For example, calling the WriteXml() function of a DataSet serializes this DataSet into a XML file.

ds.WriteXml("data.xml");
And if we have such this structure:

public struct User
{
   public int id;
   public string name;
}
we can get the following results if we serialize a collection of that structure into XML:

<?xml version="1.0" encoding="utf-8"?>

<users>
   <user>
       <id>12</id>
       <name>Mark</name>
   </user>
   <user>
       <id>13</id>
       <name>Charles</name>
   </user>
   <user>
       <id>14</id>
       <name>John</name>
   </user>
</users>

Read more: Just Like a Magic

Posted via email from jasper22's posterous

0 comments: