5
Answers

NP65 BinarySearch() method

Ask a question
Maha

Maha

16y
3.2k
1

Hi Guys

 

NP65   BinarySearch() method

 

Following simple program shows the way implementation of BinarySearch() method.

 

http://www.java2s.com/Tutorial/CSharp/0220__Data-Structure/MethodsDefinedbyArray.htm

 

But in the above website BinarySearch() method has been shown in the following way. What does this mean and how can this be implemented.

 

public static int BinarySearch(Array a, object v) 

 

Anyone knows please explain the reason.

 

Thank you

 

using System;

public class BinarySearchDemo

{

    public static void Main()

    {

        int[] idNumbers = { 122, 167, 204, 219, 345 };

 

        int entryId = 204;

 

        int x = Array.BinarySearch(idNumbers, entryId);

 

        Console.WriteLine("ID {0} position {1}", entryId, x);

    }

}


Answers (5)