版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wtxhai/article/details/88688001
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Example607
{
class Program
{
static void Main(string[] args)
{
string strOld = "one world,one dream."; //定义一个字符串
Console.WriteLine("原始字符串:" + strOld); //输出字符串
string strNew1 = strOld.Replace(',', '*'); //用*号代替,号
Console.WriteLine("第一种替换后的效果:" + strNew1); //输出替换后的效果
string strNew2 = strOld.Replace("one", "One");
Console.WriteLine("第二种替换后的效果:" + strNew2); //输出替换后的效果
Console.ReadLine();
}
}
}