How to trim the last character of a string in C#

1 Answer

0 votes
using System;
using System.Linq;

class Program
{
   static void Main() {
        string s = "c# programming";

        s = s.TrimEnd(s.Last());
        
        Console.WriteLine(s);
    }
}
  
  
  
  
/*
run:
  
c# programmin
  
*/

 



answered Nov 13, 2021 by avibootz

Related questions

1 answer 113 views
1 answer 77 views
77 views asked Aug 15, 2023 by avibootz
1 answer 179 views
1 answer 163 views
1 answer 101 views
101 views asked Jul 30, 2023 by avibootz
1 answer 105 views
1 answer 125 views
125 views asked Jul 10, 2020 by avibootz
...