I'm struggling to clone a list of lists of a reference type. I tried to implement ICloneable
in my reference class, however, it don't seems to call the Clone()
method in it.
Code:
public class Solid : ICloneable{
private double[,] _points; //vertices do solido
private int[,] _edges; //arestas do solido
public int[,] Faces { get; private set; } //faces do solido
public int[,] Edges {
get { return _edges; }
set { _edges = value; }
}
...
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;
}
}