Introducing Radical.sh

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

Trim in C#

We can trim the spaces using trim() in C#.

  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.  
  12. string s1 = "Forget code ";
  13.  
  14. string s2 = s1.Trim();
  15. // ! is added here to see the space present or not
  16. Console.WriteLine(s2+"!");
  17.  
  18. }
  19. }
  20. }


Output:
Forget code!

..