我使用
连接对象 GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("string1",subobject1);
info.AddValue("string2",subobject2);
}
将在流中存储什么?字符串也存储? Stream ??
中的确切存储格式如何?答案 0 :(得分:1)
将存储subobject1和subobject2值。是的,字符串也是存储的,需要能够在反序列化期间匹配传递给GetValue()的名称。
答案 1 :(得分:1)
是的,字符串存储为在随后的反序列化期间用于查找数据的键。它们将被用于反序列化的类的特殊构造函数中,如下所示:
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));
}