Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

TrimEnd in C#

Using TrimEnd, we can trim the spaces only in the end of string.

  1. using System;
  2. using System.IO;
  3. using System.Text;
  4.  
  5. namespace forgetCode
  6. {
  7. class program1
  8. {
  9. static void Main(string[] args)
  10. {
  11. string s1 = " Forget code ";
  12.  
  13. string s2 = s1.TrimEnd();
  14.  
  15. // ! is added here to see the space present or not
  16.  
  17. Console.WriteLine("!" + s2 + "!");
  18.  
  19. }
  20. }
  21. }


Output:

! Forget code!


..