C# – How to remove the linefeed or newline from a text file or cdr file including the spaces

c++

This is my situation, I was able to remove the spaces using trim or replace. But it does not remove the linefeed or newline at the end of each file. How can I remove the spaces and linefeed in C#?

Thanks in advance.

Best Solution

You can call Trim method with all characters that you want to be removed like:

line = line.Trim(' ','\r','\n');