替换特定的字符串 [英] Replace particular String

查看:136
本文介绍了替换特定的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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?


这篇关于替换特定的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆