定义接口:
public interface IDeepCloneable<T> where T : class
{ T CloneDeep(); }
定义类:
public sealed class AClass : IEquatable<AClass>,
IDeepCloneable<AClass> {....
//实现
public AClass CloneDeep()
{ return (AClass)this.MemberwiseClone(); }
//另一种实现
public AClass CloneDeep()
{ AClass newCfg = new AClass(); newCfg.m_bEnabled = m_bEnabled; newCfg.m_atooObfuscation = m_atooObfuscation; newCfg.m_strDefaultSequence = m_strDefaultSequence; foreach(AClass1 a in m_lWindowAssocs) newCfg.Add(a.CloneDeep()); return newCfg; }}