Reference types (like instance of objects) would because they might all refer to the same object
ie/ if you do
dim d as new date
dim a as date = d
because a and d refer to the same instance and so if you change a.totalseconds then d.totalsseconds also “changes”
strings are not reference types
I was trying to encourage gerardo to try things and read the references before asking here
Thats usually a good strategy
At least that way you can ask this like
“I tried this and this seems to work like … and the references aren’t clear what should happen”
A lot of the people frequenting the forums appreciate that you’ve done or tried to do that kind of “self help”
To put it another way, how would you change a string? If it were a MemoryBlock, you could modify a byte, but a String has no such tool. You can’t, for example, do something like s.Mid( 1, 1 ) = "a". All you can do is replace one string with another.
To illustrate:
a = "some string"
b = a // "some string"
a = a.Left( 4 ) // b = "some string", but a is now a new string, "some"
b = b.Left( 4 ) // b now = "some" too, and "some string" is gone
In this way, you can think of a string as an immutable object. That object can be assigned to multiple variables, but can never be modified. When nothing refers to that string anymore, it goes away.
(This underscores another point: Assigning one string variable to another does not copy the string, merely passes the reference, just like assigning one Date variable to another.)
The implementation makes them seem more like value types than immutable objects - which is nice
You don’t have to ever call NEW on a string or worry about when its released
You cant assign NIL like you could if it were an object reference
Appearances to you are that they are value types
Its an internal detail that leaked out in a few spots that they are immutable objects