首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

字符串 处理 急+++++++急解决方案

2012-01-19 
字符串 处理 急急急急急急!+++++++急急急急急急有一字符串,中间有回车,如何把回车去掉[解决办法]先转换成s

字符串 处理 急急急急急急!+++++++急急急急急急
有一字符串,中间有回车,如何把回车去掉

[解决办法]
先转换成streamreader类的对象,去掉回车符,再转换回来
StreamReader sr = new StreamReader(this.textBox1.Text,System.Text.Encoding.Default); this.textBox2.Text = sr.ReadToEnd().Replace((char)10, ' ').Replace((char)13, ' '); this.textBox2.SelectAll(); sr.Close();
[解决办法]

C# code
yourStr = System.Text.RegularExpressions.Regex.Replace(yourStr, @"\r\n", ""); 

热点排行