Strings Are Immutable
One of the interesting aspects of System.String is that once you assign a string object with its ini-
tial value, the character data
cannot be changed. At first glance, this might seem like a flat-out lie,
given that we are always reassigning strings to new values and due to the fact that the System.
String type defines a number of methods that appear to modify the character data in one way or
another (uppercasing, lowercasing, etc.). However, if you look more closely at what is happening
behind the scenes, you will notice the methods of the string type are in fact returning you a brand-
new string object in a modified format:
static void StringAreImmutable()
{
Do'stlaringiz bilan baham: |