Replacing plus sign "+" in vb.net
I am trimming some strings but I am unable to do anything about the strings containing plus signs.
For example if I have this str开发者_开发百科ing with a telephone number
Dim str As String = "+46765124246"
And try
str.replace("+46", "0")
Nothing changes in the string.
Why is this and how do I do it?
The replace function, and most sting functions are non-destructive. The original string is left alone. In order to work with the result, you need to assign the result back to a variable.
str = str.Replace("+46", "0")
or
Dim result as String
result = str.Replace("+46", "0")
Console.WriteLine(result) ' Prints '0765124246' str still equals '+42765124246'
Try...
str = str.replace("+46", "0")
精彩评论