I have a Form with two Datalog class variables
public partial class ModifyDataForm : Form
{
public DataLog DLog;
private DataLog copyCurrent;
public ModifyDataForm(DataLog log, int selectIndex = 0)
{
InitializeComponent();
DLog = (DataLog)log.Clone();
copyCurrent = (DataLog)log.Clone();
}
}
When I'm updating the value of DLog, the value of copyCurrent also changes, why?
The function in which I update the the variable is below
private void smooth_Click(object sender, EventArgs e)
{
int NValues; int POrder;
if (getSmoothParameters(out NValues, out POrder))//parameters are valid
{
float[] yvalues = DataLog.convertStringArrayToFloats(DLog.Data[labelIndex]);
float[] newyvalues = Filters.smooth.SavitzkyGolay(yvalues, NValues, POrder);
//I am updating the values of DLog here,
//but the values of copyCurrent also changes
DLog.Data[labelIndex] = Array.ConvertAll(newyvalues, x => AuxillaryFunctions.DecimalPlaceNoRounding((double)x));
((ViewDigiFiles)this.Owner).updateSelectedLog(DLog);
((ViewDigiFiles)this.Owner).glControl1.Invalidate();
}
else//parameters are NOT valid
{
MessageBox.Show("Invalid smoothing parameters.");
return;
}
}