serialization: 1. use attribute // "[serializable]" 2. formatter // "binaryformatter binaryformatter = new binaryformatter();" 3.[noserialized]
//example // if the data can generate based some data, then no need to serialize them. // overload the onserialization() method to do the caculate work [serializable] class products : ideserializationcallback { private long statnumber = 1; private long endnumber; [nonserialized] private long[] theproducts; ... public static void main() { products p = new products(1, 10); p.serialize(); products p2 = products.deserialize(); p2.displayproducts(); } public void serialize() { filestream filestream = new filestream("doproducts1.out", filemode.create); binaryformatter.serialize(filestream, this); filestream.close(); } public static products deserialize() { filestream filestream = new filestream("doproduct1.out", filemode.open); binaryformatter binaryformattter = new binaryformatter(); products p = (products) binaryformatter.deserialize(filestream); filestream.close(); return p; }
pubic virtual void ondeserialization(object sender) { //caculate the none serialized data based on the serialized data }
}
activex control: 1. write in vb or vc 2. register activex control in dos command windows regsvr32 a.ocx 3. add control to c# project // tool->customize toolbox->com components->select your component 4. call // label1.text = axcalculator.add(ref left, ref right).tostring;