Given:
var x = "abc";
var x = "[abc]";
I coded the following to remove the [ and ] characters.
x1 = x.Replace("[", "");
x2 = x1.Replace("]", "");
Is there some way that looks more clean to do this? Can I for example string one replace after the other? Note that the [ and ] if they appear will be found always at the start and the end of the string.
string newstring = x.Trim('[', ']');
Can I for example string one replace after the other?
Yes:
var result = x.Replace("[", "").Replace("]", "");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With