Deep Copy in C# (Cloning for a user defined class)
来源:互联网 发布:单片机和plc的前景 编辑:程序博客网 时间:2024/05/21 11:32
原文:http://www.c-sharpcorner.com/UploadFile/sd_surajit/cloning05032007012620AM/cloning.aspx
Have you ever used the Clone() method of DataSet? This method creates an empty class with same structure as original DataSet.
You can write your own clonable classes. To do so, you must implement IClonable. The following code shows a clonable Test class.
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
public
{
public Test()
{
}
// deep copy in separeate memory space
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;
}
}
Class Test : IClonable
- Deep Copy in C# (Cloning for a user defined class)
- Base class for cloning an object in C#
- A Multi-View Deep Learning Approach for Cross Domain User Modeling in Recommendation Systems
- A guide to object cloning in java
- 转载:C# .NET Tips: Deep Cloning an Object
- c# class copy class
- Defining a Copy Constructor for a Reference Class Type
- User-Defined Types in C
- User defined hash in C++
- Copy Constructor versus Cloning
- Error creating bean with name 'UserManger' defined in class path resource [user/applicationContext.x
- Disabling Copy/Paste in a Textbox control in C#
- C#深度拷贝(Deep Copy)
- Cannot refer to a non-final variable i inside an inner class defined in a differ
- Cannot refer to a non-final variable inside an inner class defined in a different method
- 典型 cloning, copy, copyWithZone:, NSCopyObject()
- Using User Defined Types in COM & ATL
- Using User Defined Types in COM & ATL
- Linux内核2.6.14源码分析-双向循环链表代码分析(巨详细)
- Eclipse 安装配置总结
- 毕业照相
- Symbian 真机http上传下载文件
- 建立socket崩溃的问题
- Deep Copy in C# (Cloning for a user defined class)
- hahahahahahaah
- Linux驱动入门
- escape,encodeURI,encodeURIComponent函数比较
- CVS服务器在Windows的安装配置
- fuck
- 清除SQLServer日志的两种方法
- Sun推获益计划让开源开发者劳有所获
- WPF中ListView小Demo的数据绑定应用.