System.Enum.BinarySearch C# (CSharp) Method

BinarySearch() private static method

private static BinarySearch ( ulong array, ulong value ) : int
array ulong
value ulong
return int
        private static int BinarySearch(ulong[] array, ulong value)
        {
            int lo = 0;
            int hi = array.Length - 1;

            while (lo <= hi)
            {
                int i = (lo + hi) >> 1;
                ulong temp = array[i];

                if (value == temp) return i;

                if (temp < value)
                {
                    lo = i + 1;
                }
                else
                {
                    hi = i - 1;
                }
            }

            return ~lo;
        }