I was after some opinions and views in regards to immutable and mutable data types.
For example, I understand that if you were to define a string, that is creating and storing a string of char's in memory and then pointing a reference to that location? (indirect addressing?)
That makes sense, but if you then created another string with the same value, does that point to the same memory location?
This brings me on to ask, what happens when you change one of the variable values? Does it create and point to a new memory location?
I was under the impression that to do a comparison in the form of 'if stringA=stringB' was bad practice? (but if it was to create a new memory location when you change a variables value, why would this matter?)
Also, is an Integer treated the same way? If it was, would 'if intA=intB' be practice also?
How are you meant to be able to know the best way to determine comparisons?
Obviously my concerns may not be a problem within .net.
Thanks,
Leon
For example, I understand that if you were to define a string, that is creating and storing a string of char's in memory and then pointing a reference to that location? (indirect addressing?)
That makes sense, but if you then created another string with the same value, does that point to the same memory location?
This brings me on to ask, what happens when you change one of the variable values? Does it create and point to a new memory location?
I was under the impression that to do a comparison in the form of 'if stringA=stringB' was bad practice? (but if it was to create a new memory location when you change a variables value, why would this matter?)
Also, is an Integer treated the same way? If it was, would 'if intA=intB' be practice also?
How are you meant to be able to know the best way to determine comparisons?
Obviously my concerns may not be a problem within .net.
Thanks,
Leon