//Visual Basic 2008/2010 Recursie Procedures en Functies public class Exercise4Solution { void Main() { int[] numbers; int number; int lowerbound; int upperbound; bool found; number = 15; lowerbound = 0; upperbound = 9; found = this.BinarySearch(number, numbers, lowerbound, upperbound); Console.WriteLine(found); number = 18; lowerbound = 0; upperbound = 7; found = this.BinarySearch(number, numbers, lowerbound, upperbound); Console.WriteLine(found); Console.ReadLine(); } void BinarySearch(int number, int[] array, int lowerbound, int upperbound) { int middle = ((lowerbound + upperbound) / 2); if ((number == this.array(middle))) { BinarySearch = true; } else { if ((upperbound <= lowerbound)) { BinarySearch = false; } else { if ((number > this.array(middle))) { lowerbound = (middle + 1); } else { upperbound = (middle - 1); } BinarySearch = this.BinarySearch(number, array, lowerbound, upperbound); } } } } //Bezoek www.vbvoorbeelden.be voor meer C# voorbeelden. //Copyright - De Wolf / vbvoorbeelden - 2003-2010 - Alle rechten voorbehouden.