1

I am Serialing an object using

 GetObjectData(SerializationInfo info, StreamingContext context) { info.AddValue("string1",subobject1); info.AddValue("string2",subobject2); } 

what will be stored in stream? do the strings also store? How will be the exact storage format in Stream??

1
  • The exact storage format is a proprietary implementation detail that you shouldn't need to know precisely because it isn't guaranteed. If you need a known format, then use a different serializer. BinaryFormatter makes no promises here. Commented Mar 12, 2010 at 13:15

2 Answers 2

1

The subobject1 and subobject2 values will be stored. Yes, the string are also stored, needed to be able to match the name passed to GetValue() during deserialization.

Sign up to request clarification or add additional context in comments.

1 Comment

You cannot get that, the binary serialization format is not documented and subject to change.
1

Yes, the strings are stored as the keys by which to look up the data during the subsequent deserialization. They would be used in a special constructor of the class being deserialized, something like this:

public YourClass(SerializationInfo info, StreamingContext ctxt) { //Get the values from info and assign them to the appropriate properties this.String1 = (String)info.GetValue("string1", typeof(string)); this.String2 = (String)info.GetValue("string2", typeof(string)); } 

2 Comments

How will be tha exact format that the serialized object stored in stream?
As Mark and Hans remarks, that is not documented. I guess you could inspect the content of the stream and try to analyze it, but don't think it would be a good idea. Why do you need the exact format?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.