欢迎光临
我们一直在努力

C#学习笔记之八(Serialization, ActiveX Control)-.NET教程,C#语言

建站超值云服务器,限时71元/月

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;

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » C#学习笔记之八(Serialization, ActiveX Control)-.NET教程,C#语言
分享到: 更多 (0)

相关推荐

  • 暂无文章