Here's my string
string str = "a";
Now I use string.Remove()
str.Remove(0);
Console.WriteLine(str);
The character 'a' is still there, why is this?
Here's my string
string str = "a";
Now I use string.Remove()
str.Remove(0);
Console.WriteLine(str);
The character 'a' is still there, why is this?
Strings are immutable. When you have set a string equal to a value, that value does not change in and of itself. Rather, changes are returned in a new string object.
To see your changes, you would write something like
string str = "a";
str = str.Remove(0);
Immutable huh? I'm going to have to look that one up.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.