C#程序用星号替换句子中的字符
使用Replace()方法用星号替换字符。
假设我们的字符串是-
string str = "dem* text";
要替换它,请使用Replace()方法-
str.Replace('*', 'o');这是完整的代码-
示例
using System;
public class Program {
public static void Main() {
string str = "dem* text";
Console.WriteLine("Initial string = " + str);
string res = str.Replace('*', 'o');
//更换后
Console.WriteLine("After replacing asterisk = " + res.ToString());
}
}输出结果Initial string = dem* text After replacing asterisk = demo text
热门推荐
10 公司同事回归祝福语简短
11 七姐妹新春祝福语简短
12 网络段子祝福语大全简短
13 送水杯祝福语女生简短
14 升职蛋糕祝福语大全简短
15 小寒健康祝福语大全简短
16 满岁女宝祝福语简短
17 水晶婚夫妻祝福语简短
18 祝福语美甲店员工简短