Vb.net 换绳练习

Vb.net 换绳练习,vb.net,Vb.net,如何替换该字符串,以便在替换工作完成后,该字符串将没有任何空格 这是字符串: dim InitialString as string = "Hello world !!!" 要使用字符串替换,您可以这样做: dim InitialString as string = "Hello world !!!" ' We can use the Replace method like this InitialString = InitialString.Replace("world", "planet

如何替换该字符串,以便在替换工作完成后,该字符串将没有任何空格

这是字符串:

dim InitialString as string = "Hello world !!!"

要使用字符串替换,您可以这样做:

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 

你是说只有空间<代码>“dim InitialString as string=\”你好,世界\“.Replace(“,”)我以为他说的是空间,就像在内存中一样space@Cybernate:您的代码不工作。VS表示“Expression Expected”@Yoga:在一个好问题中,您还将提供所需的结果字符串。避免了这么多猜测。@Yoga:你被否决了,因为你在提问之前没有做适当的研究,或者你的问题表明你没有努力。您应该阅读常见问题解答。请不要告诉VB.NET的新用户将内容设置为“无”
,它经常被误用且不必要…@minitech您完全正确,但我不确定OP是问如何释放()字符串,还是他们问如何删除空格您也可以使用
myString=myString.Replace(“,string.Empty)
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