How to remove carriage return and linefeed from the end of a string in C#

1 Answer

0 votes
using System;

class Program
{
    static void Main() {
        string str = "c# c++ c python\r\n\n\n\r\n\r\r";
        
        str = str.TrimEnd('\r', '\n');

        Console.Write(str);
    }
}




/*
run:

c# c++ c python

*/

 



answered Nov 17, 2023 by avibootz
...