c# - Not removing a substring from a string -
i trying remove substring string in simple code. c# not removing it:
stringcmd = "haha wowi in love!" stringcmd.remove(stringcmd.indexof("wow"), 5);
after removing should "haha in love!"
string.remove
method returns new string without modifying 1 passed parameter, have assign variable:
stringcmd = stringcmd.remove(stringcmd.indexof("wow"), 5);
you should aware string
s in .net immutable. can read more on msdn: string
(c# reference).
Comments
Post a Comment