Use the BinarySearch() method to search intArray for the number 4 : Array Search : Data Structure C# Examples


C# Examples » Data Structure » Array Search »

 

Use the BinarySearch() method to search intArray for the number 4









    
using  System;

class  MainClass
{

    public  static  void  Main()
    {
        int[]  intArray  =  {5,  2,  3,  1,  6,  9,  7,  14,  25};
        Array.Sort(intArray);
        
        int  index  =  Array.BinarySearch(intArray,  4);
        Console.WriteLine("Array.BinarySearch(intArray,  4)  =  "  +  index);
    }

}
    
   
  
   



Output

Array.BinarySearch(intArray, 4) = -4


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Structure
» Array Search