Reputation: 277
I have a
string myStringTitle= "Insurance Subsequent Action - Removing Coverage";
I use the method
myStringTitle.replace("-", "");
and also
Regex.Replace(myStringTitle, @"[^-]", ""); <br>
none of them seems to work any reason why?. thanks
Upvotes: 0
Views: 2481
Reputation: 26655
Strings are immutable. Replace()
will create a new string and you must assign the result to a variable. It does not modify the string in-place.
So, change your code as:
myStringTitle = myStringTitle.Replace("-", "");
Upvotes: 6