c#去掉字符串中的回车符

来源:互联网 发布:mac win10 触摸板设置 编辑:程序博客网 时间:2024/06/06 18:35

先转换成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(); 
OR

有个更简单的方法 s.Replace("/r","");