
浅拷贝
public Person QianKaoBei()
{
    //一句话实现浅拷贝
    return this.MemberwiseClone() as Person;
    //MemberwiseClone的作用就是把当前对象浅拷贝一份。
}
深拷贝
[Serializable]
	public class Person
	{
		public string Name { get; set; }
		public int Age { get; set; }
		//通过序列化与反序列化会将当前对象实现一次深拷贝
		public Person ShenKaoBei()
		{
			BinaryFormatter bf = new BinaryFormatter();
			using(MemoryStream ms = new MemoryStream())	//二进制序列化需要一个流,因为这个流不用往文件写, 在内存用一下流就可以了,所以用了内存流
			{
				bf.Serialize(ms, this);		//把当前这个对象序列化到流里, 完成序列化. 前提是类打了这个特性[Serializable],类里的所有类型(应该是自定义类)也打上
				//跟接着就执行反序列化
				ms.Position = 0;
				return bf.Deserialize(ms) as Person;
			}
		}
	}
底下两个深拷贝都可以
/*
public List<Point> Clone(List<Point> inputList)
{
	BinaryFormatter Formatter = new BinaryFormatter(null, new StreamingContext(StreamingContextStates.Clone));
	System.IO.MemoryStream stream = new System.IO.MemoryStream();
	Formatter.Serialize(stream, inputList);
	stream.Position = 0;
	var outList = Formatter.Deserialize(stream) as List<Point>;
	stream.Close();
	return outList;
}
*/
		
public List<Point> Clone(List<Point> inputList)
{
	BinaryFormatter bf = new BinaryFormatter();
	using(MemoryStream ms = new MemoryStream())
	{
		bf.Serialize(ms, inputList);
		ms.Position = 0;
		return bf.Deserialize(ms) as List<Point>;
	}
}
深拷贝(泛型)
if (points.Count == 0) return;
int length = points.Count;
//g.DrawLine(pen2, points[length - 1], point2);
startFlag = false;
if (points.Count >= 2)
{
	points_dc = new List<Point>();
	//points_dc = Clone(points);
	points_dc = MyClass<List<Point>>.MyClone(points);
	pointsArr.Add(points_dc);
}
points.Clear();
public class MyClass<T>
{
	public static T MyClone(T inputList)
	{
		BinaryFormatter bf = new BinaryFormatter();
		using (MemoryStream ms = new MemoryStream())
		{
			bf.Serialize(ms, inputList);
			ms.Position = 0;
			return (T)bf.Deserialize(ms);
		}
	}
}
        //public <T> Clone(<T> inputList)
	//{
	//	BinaryFormatter bf = new BinaryFormatter();
	//	using (MemoryStream ms = new MemoryStream())
	//	{
	//		bf.Serialize(ms, inputList);
	//		ms.Position = 0;
	//		return bf.Deserialize(ms) as List<Point>;
	//	}
	//}
	public T Clone<T>(T inputList)
	{
		BinaryFormatter bf = new BinaryFormatter();
		using (MemoryStream ms = new MemoryStream())
		{
			bf.Serialize(ms, inputList);
			ms.Position = 0;
			return (T)bf.Deserialize(ms);
		}
	}
	//public List<T> ListClone(List<T> inputList)
	//{
	//	BinaryFormatter Formatter = new BinaryFormatter(null, new StreamingContext(StreamingContextStates.Clone));
	//	System.IO.MemoryStream stream = new System.IO.MemoryStream();
	//	Formatter.Serialize(stream, inputList);
	//	stream.Position = 0;
	//	List<T> outList = Formatter.Deserialize(stream) as List<T>;
	//	stream.Close();
	//	return outList;
	//}
}
public class MyClass<T>
{
	public static T MyClone(T inputList)
	{
		BinaryFormatter bf = new BinaryFormatter();
		using (MemoryStream ms = new MemoryStream())
		{
			bf.Serialize(ms, inputList);
			ms.Position = 0;
			return (T)bf.Deserialize(ms);
		}
	}
}