Split strings by three tokens : String Split Join : String C# Examples


C# Examples » String » String Split Join »

 

Split strings by three tokens









    
using  System;  
  
class  MainClass  {  
    public  static  void  Main()  {  
        string  str  =  "while  if  for,  public  class  do.";  
        char[]  seps  =  {'  ',  '.',  ','  };  
  
        //  Split  the  string  into  parts.  
        string[]  parts  =  str.Split(seps);  
        Console.WriteLine("Pieces  from  split:  ");  
        for(int  i=0;  i  <  parts.Length;  i++)  
            Console.WriteLine(parts[i]);  
        
    }  
}
    
   
  
   



Output

Pieces from split:
while
if
for

public
class
do


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo String
» String Split Join