如何替换此字符串,以便在替换工作后字符串将没有任何空格?
这是字符串:
dim InitialString as string = "Hello world !!!"
答案 0 :(得分:3)
Dim myString As String = "Hello world !!!"
myString = myString.Replace(" ","")
答案 1 :(得分:1)
要使用字符串替换,您可以这样做:
dim InitialString as string = "Hello world !!!"
' We can use the Replace method like this
InitialString = InitialString.Replace("world", "planet")
' InitialString now says "Hello planet !!!"
' We can remove the ' ' SPACE character by replacing it with an empty string
InitialString = InitialString.Replace(" ", "")
' We release the resources that InitialString uses like this :
InitialString = NOTHING