Home Feedback About project

Remove line breaks with C#

If you need to remove line breaks from text with C# you can use next string method:

  • public string Replace(string oldValue, string newValue)

Replace - returns a new string in which all occurrences of a specified string in the current instance are replaced with another specified string.

Environment.NewLine Property A string containing "\r\n" for non-Unix platforms, or a string containing "\n" for Unix platforms.

To remove line breaks using C# see example:

    s = s.Replace(Environment.NewLine, " ");
© 2010-2016
Remove line breaks with C++ - learn how to remove line breaks using C#