Introducing Radical.sh

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

Remove leading spaces in a string using TRIM in C#

TrimStart() will remove only the leading white space characters.

Syntax:
  1. stringtext.TrimStart();


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.TrimStart());
  14. }
  15. }
  16. }


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