我的任务是使物体的序列化和脱硫。
I want to know:
- Whether my object is serialized in the way I m doing it
- How I get to know that my object is being serialized or deserialized
我不是通过Serialize方法学中的物体,而是通过object.properties
。 这是否以任何方式影响到它?
FileStream fs = new FileStream(@"D:Rough WorkSerializationSerializationinDebugLog.txt",FileMode.OpenOrCreate);
Laptop obj = new Laptop();
obj.Model = 2;
obj.SerialNumber = 4;
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(fs, obj.Model);
formatter.Serialize(fs, obj.SerialNumber);
[Serializable]
class Laptop
{
public int Model;
public int SerialNumber;
}