private static Stream SerializeTiger() { Tiger tiger = new Tiger(); tiger.Age = 12; tiger.IsTamed = false; tiger.Trainer = "Joe Soap"; tiger.Weight = 120; MemoryStream stream = new MemoryStream(); BinaryFormatter fmt = new BinaryFormatter(); fmt.Serialize(stream, tiger); stream.Position = 0; return(stream); }
private static void DeserializeTiger(Stream stream) { stream.Position = 0; BinaryFormatter fmt = new BinaryFormatter(); Tiger tiger = (Tiger)fmt.Deserialize(stream); }