Can a String object behave like other reference objects such as in the case below?
class MyClass
{
public String Text = "";
}
MyClass a = new MyClass();
a.Text = "Text in a.Text";
MyClass b = a;
b.Text = "Text in b.Text";
Debug.WriteLine(a.Text); // Prints 'Text in b.Text"
String a = "Text in a";
String b = a;
b = "Text in b";
Debug.WriteLine(a); // Prints 'Text in a"
Is there a way to make the second example so that the end result is 'Text in b'? I thought 'String' was a reference class, then shouldn't the statement 'String b = a' create b as a reference to 'a'?
I'm misunderstanding something fundamental here, any tips appreciated.
- Pops