Yes, reference types are disputed by reference.
If you want to have a separate instance, you want CLONE your instance.
Create a Vector3D.Clone () method that looks something like this:
public Vector3D Clone() { return new Vector3D(this.x, this.y, this.x); }
Then your main function should look like this:
static void Main(string[] args) { Vector3D a, b; a = new Vector3D(0, 5, 10); b = new Vector3D(0, 0, 0); b = a.Clone(); ax = 10; Console.WriteLine("vector a=" + a.ToString()); Console.WriteLine("vector b=" + b.ToString()); Console.ReadKey(); }
But as others have said, something smaller than Vector3D would be better suited as an immutable structure
Neil n
source share