I made a class:
class configurations
{
public double lowColumn1 = -1;
public double highColumn1 = -1;
public double lowColumn2 = -1;
public double highColumn2 = -1;
public double lowColumn3 = -1;
public double highColumn3 = -1;
}
I want to make an array (con1
), and make a copy of it (con2
).
I would like to change con2
so it will not change con1
.
I think it is called deep copy, is it?
It is important that the copy will not consume a lot of running time, efficiency is important.
I tried .Clone()
function which didn't help me.
Please tell me what is the most efficient way to adjust my code.
private void button8_Click(object sender, EventArgs e)
{
configurations[] con1 = new configurations[3];
con1[0] = new configurations();
con1[1] = new configurations();
con1[2] = new configurations();
configurations [] con2 = new configurations [3];
con2 = (configurations[]) con1.Clone();
con2[0].highColumn1 = 999;
}
please do not make this as a duplicate. my program is very heavy and in other topics they do not discuss time efficiency. in addition to this aspect. i am very new to programming, and i couldn't made adjustments from other answers of other questions.