Passing object by value
Posted on 2006-11-08
I'm am still fairly new to C# (and OOP in general) and I've started to stumble when it comes to passing objects by value.
I've read a lot of documentation explaining what goes on when you pass an object by value, and I understand why I'm seeing the results I'm getting. But every single article I've found just falls short of offering advice on how to overcome the problems seen by people at my level of experience. So here I am....!
How can/should I get the following sample code to output "Dink Dank Do!", not "Bish Bash Bosh!" ?
Thanks in advance.
static void Main(string args)
myTestClass mainObject = new myTestClass();
myProcessClass processObject = new myProcessClass(mainObject);
public String strProperty_1;
public String strProperty_2;
public String strProperty_3;
strProperty_1 = "Dink ";
strProperty_2 = "Dank ";
strProperty_3 = "Do! ";
public myProcessClass(myTestClass objectPassed)
objectPassed.strProperty_1 = "Bish ";
objectPassed.strProperty_2 = "Bash ";
objectPassed.strProperty_3 = "Bosh! ";