Search a string from the start or from the end : String Search : String C# Examples


C# Examples » String » String Search »

 

Search a string from the start or from the end









    
using  System;    
    
class  MainClass  {      
    public  static  void  Main()  {      
        string  str1  =  "ABCDEabcde1234567e890";      
    
        //  search  string  
        int  idx  =  str1.IndexOf("e");    
        Console.WriteLine("Index  of  first  occurrence  of  One:  "  +  idx);    
        idx  =  str1.LastIndexOf("e");    
        Console.WriteLine("Index  of  last  occurrence  of  One:  "  +  idx);    
            
    }      
}
    
   
  
   



Output

Index of first occurrence of One: 9
Index of last occurrence of One: 17


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo String
» String Search