Showing posts with label Difference. Show all posts
Showing posts with label Difference. Show all posts

Saturday, September 14, 2013

Difference between Xml Serialization and Binary Serialization

There are following differences between Xml Serialization and Binary Serialization.
1. In Xml Serialization, the object is converted to XML file and in Binary Serialization, object is converted into a binary file.
2. Since object is converted into Xml file in Xml Serialization and hence it is easily portable to other platform to reuse but in Binary Serialization, object is converted to native binary copy of that object and hence it is not portable to other platform because every platform has their own native structure.
3. In Xml Serialization, some of object state is only saved but in Binary Serialization, entire object state is saved.
4. Xml Serializer serializes only public member of object but Binary Serializer serializes all member whether public or private.
5. In Xml Serializer, the class should have default constructor and class should itself have public but Binary Serializer neither require default constructor nor default access.
6. Xml Serializer requires type of object to be serialized or deserialized but Binary Serializer need not worry about the type of object.
7. Xml Serializer need not mention serializable attribute on the class but Binary Serializer need serializable attribute.
8. Xml is more interoperable and human readable than binary.
9. Binary Serialization is more efficient and fast. We can write an object in binary form little faster than Xml or text. Binary data saves memory and bandwidth and easier to parse than XML.
10. In Xml Serialization, we use namespace named System.Xml.Serialization but in Binary Serialization, we use namespace named System.RunTime.Serialization.Formatters.Binary.
 

Friday, September 13, 2013

Difference between event and delegate



An event is message or information sent by an object to signal the occurrence of an action. Action can be anything like some logic in code being triggered or any mouse event or third party actions. There are two things called as event sender and event receiver. The object that raises the event is called as event sender and the object that captures and handles the event and provides proper response to it.
One important thing is that object sender is not aware about the class or method being handled after the event rose. It indicates that some references must be there to point the class or methods to run the whole process smoothly.
To fulfill this purpose the .Net Framework provides the concepts of Delegate. It is a class that contains the reference or pointer to a method or class and having unique signature and even it points to only those methods that have same signature as delegate has.
Let us see an example:
 

Here, we can see the signature of both delegate and methods inside the class.

Copyright © Codingnodes,2014.All Rights Reserved.