Hi all!
I have a array problem I can not figure out.
I have an array that I copy in a method and returns the copy,
but I do not get a copy of the array. I just get strange values.
public class AClass
{
private float[] original = new float[5];
private float[] finalyStore = new float[5];
public AClass()
{
//init orginal
original[0] = .....
finalyStore = testToCopy();
}
private float[] testToCopy()
{
float[] copyOfOriginal = new float[5];
for(int i=0; i < original.length; i++)
{
copyOfOriginal[i] = original[i];
}
return copyOfOriginal;
}
}
The code is just a short snippet to clear out what I mean.
What comes out in "finalyStore" is not the same as "original".
If I just copy the entire array it works fine:
copyOfOriginal = original;
return copyOfOriginal;
What am I missing? Where do I think wrong?
Many thanks in advance!
Marcux