替换特定的字符串

问题描述:

如何替换给定字符串中的特定字母

How to replace particular letter in given string

YourText = YourText.Replace("c"c,"x"c)

更新:添加了一个"c"以将字符串转换为字符.
YourText = YourText.Replace("c"c,"x"c)

Update: Added a "c" to cast the string to character.


您是否还要检查字符串的不同属性和方法?您可以使用string.Replace方法来替换字符和字符串.

Did you even bother to check the different properties and methods of string? You can use the string.Replace method to replace both characters and strings.

Dim s As String = "How are you doing?"
Dim newString As String = s.Replace("H"c,"h"c)


结果:你好吗?


Result : how are you doing?