static void Main() { Console.WriteLine("\nEnter numbers to fill list (press enter to stop):\n"); var inputList = ListCreator.CreateList(); inputList = BinarySearcher.SortList(inputList); Console.WriteLine("\nEnter number to seach\n"); var numberToSearch = IOHelper.ParseInput(); var result = BinarySearcher.BinarySearch(inputList, numberToSearch); if (result > 0) { Console.WriteLine("Element found " + result); } else { Console.WriteLine("Element not found"); } }
static void Main(string[] args) { Console.WriteLine("BinarySearch"); BinarySearcher search = new BinarySearcher(); int[] test = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; int find = -1; int result = search.BinarySearch(test, find); if (result == -1) { Console.WriteLine($"{find} is not in the array"); } else { Console.WriteLine($"index of:{find} is {result}"); } Console.Read(); }