Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is TYPE FIDELITY in the context of object serialization?

Tags:

c#

.net

I am trying to serialize a generic class. I will store this Serialization to disk. When looking over the MSDN it said this.

Binary serialization preserves type fidelity, which is useful for preserving the state of an object between different invocations of an application.

What does Type Fidelity mean? Will this preserve the type of object which is saved? Is there a "better" way of achieving what I want to do than serializing the object and saving it to disk?

public class foo<T>
{
       public T coolProperty {get; set;}
}
like image 862
gh9 Avatar asked Nov 02 '22 23:11

gh9


1 Answers

Binary serialization includes the complete state of the object, so that when you deserialize (such as in another invocation of the same application) you get an exact copy back. So yes, it will preserve the type. XML serialization includes only the public properties of the object, and is useful for passing the object data between different platforms.

like image 67
Ryan M Avatar answered Nov 08 '22 07:11

Ryan M