Introducing Radical.sh

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

Remove spaces in a string using TRIM in C#

TRIM() function will trim the string text (Only at beginning and trailing spaces)

Syntax:
  1. stringtext.TRIM();


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.  
  11. static void Main(string[] args)
  12. {
  13. string text = " My name is Forget Code ";
  14. Console.WriteLine(text.Trim());
  15. }
  16. }
  17. }


Output:
With no spaces at leading and trailing
My name is Forget Code