Introducing Radical.sh

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

Remove trailing spaces in a string using TRIM in C#

TrimEnd() will remove only the trailing white space characters.

Syntax:
  1. stringtext.TrimEnd();


Example:
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ForgetCode
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. string text = " My name is Forget Code ";
  13. Console.WriteLine(text.TrimEnd());
  14. }
  15. }
  16. }


Output:
(With only leading spaces not trailing spaces)
My name is Forget Code