如何实现 UserControl 深表复制 如何实现ICloneable接口的Clone方法? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 示例: [Serializable] public class Test : ICloneable { public string abc; public string add; public object Clone() { MemoryStream ms = new MemoryStream(); BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(ms, this); ms.Position = 0; object obj = bf.Deserialize(ms); ms.Close(); return obj; } }//....Test test1= new Test();test1.abc="zhang";test1.add="jason";Test test2 = (Test) test1.Clone(); 谢谢'大康',用户控件是要从System.Windows.Forms.UserControl继承的,System.Windows.Forms.UserControl是不可序列化的。所是你提供的方法还是不行。 sql2008中调用扩展存储报错,有谁遇到过? 编写串口出了点问题,求解 DevExpress chartControl Zoom功能问题!!! 一个菜鸟问题 如何将图片转化为LED屏幕可以显示的2进制数据 windows 写入IP地址后,自动填充子网掩码,那个功能拿C#怎么实现吗? 基类的构造函数的意义 没有访问目录xxxx的权限 求Borland.Together.for.Microsoft.Visual.Studio.NET.v2.0 下载地址?? 我在下载频道下载并评价资源后,为什么没有返还积分? forms验证的问题 用C#做了个收银系统,但不知怎么打开钱箱,钱箱是与打印机连接的
[Serializable]
public class Test : ICloneable
{
public string abc;
public string add;
public object Clone()
{
MemoryStream ms = new MemoryStream();
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(ms, this);
ms.Position = 0;
object obj = bf.Deserialize(ms);
ms.Close();
return obj;
} }
//....
Test test1= new Test();
test1.abc="zhang";
test1.add="jason";
Test test2 = (Test) test1.Clone();