I want to know about the term "Serialization". Although, I have read many books, but the concept is not clear yet.
Please reply with an easy and live example, if possible.
Thanks a ton in advance......
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Zoran HorvatPosted Jul 18, 2011, 8:05 AM
Term "serialization" is derived from the fact that object which might be scattered in memory is now put into series of successive memory locations. As such, it can be written into file, sent over network, etc.
Main point about serialization is that resulting series can be de-serialized into another instance which is identical to the instance which was originally serialized. This implies that serialization is a lossless process. On the contrary, if object is serialized into, say string, with loss of data, then it could rather be called formatting - string is formatted to depict content of the object, but no opposite process is possible, i.e. object cannot be reconstructed from the formatted string.
.NET uses reflection to investigate serializable types and to create wrapper classes which are capable to create XML elements for public properties quickly. Whenever you use new Serializer(typeof(MyClass)), .NET will effectively instantiate object of generated wrapper class which has all properties equal as MyClass, but some additional methods that allow quick formatting back and forth between MyClass objects and XML elements.
You can also refer to my article Best Practices in .NET XML Serialization of Complex Classes for some techniques applied to XML serialization of complex classes.
Hope this helped.
Zoran