public static void Main(string[] argv) { if (argv.Length == 1) { ip2country ic = new ip2country( "ip2cntry.dat" ); TimeSpan span; DateTime end; DateTime start = DateTime.Now; int countryidx = ic.lookup( argv[0] ); switch ( countryidx ) { case -1: Console.WriteLine( "{0} is not in the database", argv[0] ); break; case -2: Console.WriteLine( "{0} doesn't seem to be a valid IP number.", argv[0] ); break; case -3: Console.WriteLine( "ip2cntry.dat is not a valid database" ); break; default: String country = ic.countryCode( countryidx ); end = DateTime.Now; span = new TimeSpan( end.Ticks - start.Ticks ); Console.WriteLine( "{0} is in {1} - took {2} ms", argv[0], country, Math.Round(span.TotalMilliseconds) ); break; } } else { Console.WriteLine( "Usage: ip2c <IP address>" ); } }