zoukankan      html  css  js  c++  java
  • 深度复制

     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 
  • 相关阅读:
    hbase2.x错误记录之 disable表卡住
    hbase2.x 错误记录之 procedure is still running
    yarn timelineserver v2 配置
    Linux 系统出现大量的CLOSE_WAIT
    hbase 2.x 异常记录之 hbase shell不能分配内存
    spark 访问 hive,不能获取到数据信息
    hive 由于distcp导致执行sql慢
    Hbase 安装部署
    MooseFS安装部署
    hbase2.x 单节点启动,master挂掉
  • 原文地址:https://www.cnblogs.com/msnadair/p/1695474.html
Copyright © 2011-2022 走看看