字符串替换 string str = "yes....";str = str.Replace( "yes" , "no") 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Replace就是了比如:string a="this is word :yes";a.Replace("yes","no"); sorry,的确是和LZ的意思反了哈!----------------- // 摘要: // 将此实例中的指定 System.String 的所有匹配项替换为其他指定的 System.String。 // // 参数: // oldValue: // 要替换的 System.String。 // // newValue: // 要替换 oldValue 的所有匹配项的 System.String。 // // 返回结果: // 等效于此实例,但将 oldValue 的所有实例都替换为 newValue 的 System.String。 public string Replace(string oldValue, string newValue); //呵呵string str = "no....";str = str.Replace( "no" , "yes") 少了个分号string str = "no....";str = str.Replace( "no" , "yes"); str = str.Replace( "no","yes");嘿嘿 分杯羹可以不? 控制台程序,是否要用Console.Readline()之类的来读取输入值呢? str = str.Replace("no", "yes"); str = str.Replace( "no" , "yes"); static void Main(){ string input = Console.ReadLine(); string result; result = System.Text.RegularExpressions.Regex.Replace(input, "no", "yes"); // OR // result = result.Replace("no", "yes"); Console.Write(result); Console.ReadLine(); } windows7下发布项目删除功能不可用 C# 在不同类里调用功能 关于序列化和放射 高分 急 一般人都会的比较问题 牛人勿进 如何判断一个字符串全是数字? 一个问题 能给学c#的新手,一个整体学习过程吗· 关于webbrowser 怎么用c#存储显示图象数据! 在C#中如何实现调用带参数的线程 正则表达式怎么写?请大家帮忙!!! 菜鸟请教,c#创建存储过程
比如:
string a="this is word :yes";
a.Replace("yes","no");
-----------------
// 摘要:
// 将此实例中的指定 System.String 的所有匹配项替换为其他指定的 System.String。
//
// 参数:
// oldValue:
// 要替换的 System.String。
//
// newValue:
// 要替换 oldValue 的所有匹配项的 System.String。
//
// 返回结果:
// 等效于此实例,但将 oldValue 的所有实例都替换为 newValue 的 System.String。
public string Replace(string oldValue, string newValue);
string str = "no....";
str = str.Replace( "no" , "yes")
string str = "no....";
str = str.Replace( "no" , "yes");
嘿嘿 分杯羹可以不?
string input = Console.ReadLine();
string result;
result = System.Text.RegularExpressions.Regex.Replace(input, "no", "yes");
// OR
// result = result.Replace("no", "yes");
Console.Write(result);
Console.ReadLine();
}