Array.BinarySearch : Array « System « C# / C Sharp by API






Array.BinarySearch

 

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, 5);
    Console.WriteLine("Array.BinarySearch(intArray, 5) = " + index);
  }

}

   
  








Related examples in the same category

1.Array.AsReadOnly
2.Array.Clone
3.Array.ConvertAll
4.Array.Copy
5.Array.CopyTo
6.Array.Count
7.Array.CreateInstance
8.Array.Exists
9.Array.Find
10.Array.FindAll
11.Array.ForEach
12.Array.GetEnumerator()
13.Array.GetLength()
14.Array.GetLowerbound
15.Array.GetUpperBound
16.Array.IndexOf
17.Array.LastIndexOf
18.Array.Length
19.Array.Rank
20.Array.Resize
21.Array.Reverse
22.Array.Reverse(nums, 1, 3)
23.Array.Sort
24.Array.Sort(names, Comparer.DefaultInvariant)
25.Array.SyncRoot