Expand|Select|Wrap|Line Numbers
- using System;
- public class CheckZIPS
- {
- public static void Main()
- {
- string[] zips = {"BF 45633", "GJ 76895", "BK 87946", "NM 38657"};
- int x;
- string enterzip;
- Console.Write("Enter Zip code: ");
- enterzip = Console.ReadLine();
- x = Array.BinarySearch(zips, enterzip);
- if(x < 0)
- Console.WriteLine("Zip {0} not found", enterzip);
- else
- Console.WriteLine("Zip {0} was found at position {1}",
- enterzip, x);
- }
- }