0

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?

2
Contributors
2
Replies
5
Views
7 Years
Discussion Span
Last Post by DaveTran
2

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);
Votes + Comments
like a walking textbook :)
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.