//Visual Basic 2008/2010 Binair Zoeken in Arrays Arrays public class ExerciseSolution { void Main() { int count = 3; string[] names; int[] zipCodes; Console.WriteLine("Zip Code ?"); string zipCode = Console.ReadLine(); bool found; bool exhausted; int lowerbound; int index; int upperbound = (count - 1); for (; (found || exhausted); ) { index = ((lowerbound + upperbound) / 2); found = (zipCode == this.zipCodes(index)); exhausted = (upperbound <= lowerbound); if (((found || exhausted) == false)) { if ((zipCode > this.zipCodes(index))) { lowerbound = (index + 1); } else { upperbound = (index - 1); } } } if (found) { Console.WriteLine(this.names(index)); } else { Console.WriteLine("City not found."); } Console.ReadLine(); } } //Bezoek www.vbvoorbeelden.be voor meer C# voorbeelden. //Copyright - De Wolf / vbvoorbeelden - 2003-2010 - Alle rechten voorbehouden.