Search a sub string in a string : String Search : String C# Examples


C# Examples » String » String Search »

 

Search a sub string in a string









    
using  System;  
  
class  MainClass  {  
    public  static  void  Main()  {  
        string  str  =  "abcdefghijk";  
        int  idx;  
  

        idx  =  str.IndexOf("def");  
        Console.WriteLine("Index  of  first  \"def\":  "  +  idx);  
    }
}
    
   
  
   



Output

Index of first "def": 3


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo String
» String Search