一路向前走

其中的代码,如果您有更好的改进,请一定提出您的宝贵意见及建议

  :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: :: 管理 ::
 1 using System;
 2 using System.Collections.Generic;
 3 using System.Text;
 4 using System.IO;
 5 using System.Runtime.Serialization.Formatters.Binary;
 6 
 7 namespace WinFormTest
 8 {
 9     [Serializable]
10     public class Class1:ICloneable 
11     {
12         private string _t1;
13         private string _t2;
14         private Class2 _c2;
15 
16         public string T1
17         {
18             get
19             {
20                 return _t1;
21             }
22             set
23             {
24                 _t1 = value;
25             }
26         }
27 
28 
29         public string T2
30         {
31             get
32             {
33                 return DateTime.Now.ToString();
34             }
35           
36         }
37 
38         public Class2 C2
39         {
40             get
41             {
42                 return _c2;
43             }
44             set
45             {
46                 _c2 = value;
47             }
48         }
49 
50         public Object Clone()
51         {
52             {  
53                 MemoryStream stream = new MemoryStream();
54                 BinaryFormatter formatter = new BinaryFormatter();
55                 formatter.Serialize(stream, this);
56                 stream.Position = 0;
57                  
58                 return formatter.Deserialize(stream);
59             }
60         }
61     
62     }
63 }
64 

 

posted on 2010-03-25 17:13  Adair  阅读(240)  评论(0编辑  收藏  举报