Use the Trim(), TrimStart(), and TrimEnd() methods to trim strings : String : String C# Examples


C# Examples » String » String »

 

Use the Trim(), TrimStart(), and TrimEnd() methods to trim strings









    
using  System;

class  MainClass
{

    public  static  void  Main()
    {
        
        string  myString18  =  '('  +  "    Whitespace    ".Trim()  +  ')';
        Console.WriteLine("'('  +  \"    Whitespace    \".Trim()  +  ')'  =  "  +  myString18);
        string  myString19  =  '('  +  "    Whitespace    ".TrimStart()  +  ')';
        Console.WriteLine("'('  +  \"    Whitespace    \".TrimStart()  +  ')'  =  "  +  myString19);
        string  myString20  =  '('  +  "    Whitespace    ".TrimEnd()  +  ')';
        Console.WriteLine("'('  +  \"    Whitespace    \".TrimEnd()  +  ')'  =  "  +  myString20);

    }

}
    
   
  
   



Output

'(' + "  Whitespace  ".Trim() + ')' = (Whitespace)
'(' + "  Whitespace  ".TrimStart() + ')' = (Whitespace  )
'(' + "  Whitespace  ".TrimEnd() + ')' = (  Whitespace)


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo String
» String