>I would like to verify something on cloning. I have a data provider class which includes this:
>
>
>Public Class Data
> Implements ICloneable
>
> Public Function Clone() As Object Implements System.ICloneable.Clone
> Return MyBase.MemberwiseClone()
> End Function
>
>
>Then, from a client class, I can do this:
>
>
> Public oData As Data = New Data(oProcess)
> Public oDataExcel As Data = New Data(oProcess)
>
> ' Keep a reference to it as we will need to switch it back after the export
> oDataExcel = oData.Clone
>
>
>This works. However, I just found out that this works only for the cloning of members and not the data itself. For example, in this case, I have a dataset attached to it such as oData.oDataSet. In that case, the data, if changed after the cloning has been done, will not be preserved.
>
>I believe something has to be changed at the Data class level in the Clone() method.
>Anyone would know what has to be done in order to assure to everything under the Data class would be cloned properly?
If I understand you correctly,
As per the doc, memberwiseClone only copies value types. As to objects (like dataset) it only copies the reference, meaning both references point to the same dataset
Maybe you want DataSet.Copy()
http://msdn.microsoft.com/en-us/library/system.data.dataset.copy(v=vs.110).aspx>
Gregory