I pass an 'global' object as a param to a method. I then init a new instance of the object and set it equal to the original, in my head i now have 2 instances of that object.
Why when i change the second instance does the first instance change? I never used 'ref'.
namespace myNamespace
{
public class myClass
{
private myObjectClass myGlobalInstance;
public void myMethod()
{
doSomething(myGlobalObject);
}
private String doSomthing(myObjectClass myObjectInstance)
{
myObjectClass newObject = myObjectInstance;
newObject.variable1 = "boo"; //this seems to change both newObject.variable1 as required AND myObjectInstance.variable1 and its calling classes object
}
}
}