Created
May 29, 2014 10:57
-
-
Save rhwy/e33f7de0804abb48040a to your computer and use it in GitHub Desktop.
a small working sample of a tool as simple as possible using webclient (and async)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace nurl1 | |
{ | |
class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
if(args.Length<1 || !(Regex.Match(args[0],@"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b").Success)) | |
throw new ArgumentException("not a valid ip number"); | |
Console.WriteLine("Country for ip [{0}]",args[0]); | |
new WebClient() | |
.DownloadStringTaskAsync("http://api.hostip.info/country.php?ip=" + args[0]) | |
.ContinueWith((t)=>{ | |
Console.WriteLine(t.Result); | |
Console.Write("Press any key to continue . . . "); | |
}); | |
Console.WriteLine("----------------------------"); | |
Console.ReadKey(true); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment