(1) [Serializable()] //Set this attribute to all the classes that you define to be serialized public class Serializeclass : ISerializable (2) Stream stream = File.Open("Serializeclass", FileMode.Create); BinaryFormatter bformatter = new BinaryFormatter(); bformatter.Serialize(stream, sc); stream.Close(); (3) stream = File.Open("Serializeclass", FileMode.Open); bformatter = new BinaryFormatter(); 物件可以serialized自己,但是無法de-serialized自己(除非透過一個空殼子)
-----文章標籤
全站熱搜
