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


C# Examples » String » String Search »

 

Search a character in a string









    
using  System;  
  
class  MainClass  {  
    public  static  void  Main()  {  
        string  str  =  "abcdefghijk";  
        int  idx;  
  
        Console.WriteLine("str:  "  +  str);  
  
        idx  =  str.IndexOf('h');  
        Console.WriteLine("Index  of  first  'h':  "  +  idx);  
  
    }  
}
    
   
  
   



Output

str: abcdefghijk
Index of first 'h': 7


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo String
» String Search