VB.NET - 从字符串中删除一个字符 [英] VB.NET - Remove a characters from a String
本文介绍了VB.NET - 从字符串中删除一个字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个字符串:
Dim stringToCleanUp As String = "bon;jour"
Dim characterToRemove As String = ";"
我想要一个删除;"的函数像这样的字符:
I want a function who removes the ';' character like this:
Function RemoveCharacter(ByVal stringToCleanUp, ByVal characterToRemove)
...
End Function
功能是什么?
答案:
Dim cleanString As String = Replace(stringToCleanUp, characterToRemove, "")
太好了,谢谢!
推荐答案
Function RemoveCharacter(ByVal stringToCleanUp, ByVal characterToRemove)
' replace the target with nothing
' Replace() returns a new String and does not modify the current one
Return stringToCleanUp.Replace(characterToRemove, "")
End Function
这里有关于 VB 的替换功能的更多信息
这篇关于VB.NET - 从字符串中删除一个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文