C#对集合进行深度复制,C#深度复制封装
场景说明
有时候方法更改外部传进来的对象,又不得不对其进行修改再返回结果时
直接上代码
pubilc class ToolX
{
public static object Clone(object obj)
{
if (obj == null || obj.GetType().BaseType == typeof(ValueType)) return obj;
try
{
Type t = obj.GetType();
if (obj is ICloneable) return (obj as ICloneable).Clone();
if (t == typeof(System.Data.DataTable)) return (obj as System.Data