The String object behaves like a value type when using the == and! =, which means that the actual object is checked, not the link.
How about passing parameters, assigning and copying?
Passing string parameters:
When a reference type is passed to a method, its reference is copied, but the underlying object remains the same.
Will this also be true for String type in C #? I mean, there are two pointers (messageVar and messageParam) pointing to the same object in the code below:
public static void main()
{
string messageVar = "C#";
Test(messageVar);
string messageVar2 = messageVar;
}
public void Test(string messageParam)
{
}
How about assigning a variable? I would suggest that the link will be copied only, and the actual object will remain the same as in String Intern Pool. Not sure.
Will messageVar2 also reference the same object?
,