Use the BinarySearch() method to search charArray for 'o' : Array Search : Data Structure C# Examples


C# Examples » Data Structure » Array Search »

 

Use the BinarySearch() method to search charArray for 'o'









    
using  System;

class  MainClass
{

    public  static  void  Main()
    {
        char[]  charArray  =  {'w',  'e',  'l',  'c',  'o',  'm',  'e'};
        Array.Sort(charArray);    //  sort  the  elements                
        int  index  =  Array.BinarySearch(charArray,  'o');
        Console.WriteLine("Array.BinarySearch(charArray,  'o')  =  "  +  index);

    }

}
    
   
  
   



Output

Array.BinarySearch(charArray, 'o') = 5


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Structure
» Array Search