Object.MemberwiseClone() instead of Copy()
Posted: Tue Jun 19, 2007 9:46 am
I noticed that the Table Type objects expose a Copy() method. It creates a new object, and field-by-field copies the variables.
However, every object already exposes the MemberwiseClone() method, which does exactly this.
Hence, my proposal would be to replace
by
.
I would also propose to add a Clone() method (which does the same) and implement the IClonable interface (a standard .NET interface)
However, every object already exposes the MemberwiseClone() method, which does exactly this.
Hence, my proposal would be to replace
Code: Select all
Public TableType Copy()
{
TableType copy = new TableType();
copy.A = A;
copy.B = B;
return copy;
}
Code: Select all
Public TableType Copy()
{
return (TableType)this.MemberwiseClone();
}
I would also propose to add a Clone() method (which does the same) and implement the IClonable interface (a standard .NET interface)