我有以下内容:
SortedDictionary<int, SortedDictionary<int, VolumeInfoItem>>
我想深拷贝。
VolumeInfoItem 是以下类:
[Serializable]
public class VolumeInfoItem
{
public double up = 0;
public double down = 0;
public double neutral = 0;
public int dailyBars = 0;
}
我创建了以下扩展方法:
public static T DeepClone<T>(this T a)
{
using (MemoryStream stream = new MemoryStream())
{
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(stream, a);
stream.Position = 0;
return (T)formatter.Deserialize(stream);
}
}
我不知道如何让 deepCopy 工作?