可以用String类的Replace方法吧:
public string Repalce(char OChar,char NChar);
public string Repalce(string OValue,string NValue);
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace _Replace
- {
- class Program
- {
- static void Main(string[] args)
- {
- string s="asdf";
- s=s.Replace('s','d');
- Console.WriteLine(s); //输出结果为:addf
- Console.ReadLine();
- }
- }
- }
复制代码 |