using System;
using System.Net;
using System.Threading;
class ThreadTest
{
static void Main()
{
WebClient wc = new WebClient();
try
{
wc.Proxy = null;
string s = wc.DownloadString("http://www.google.com");
}
catch (WebException ex)
{
if (ex.Status == WebExceptionStatus.NameResolutionFailure)
Console.WriteLine("Bad domain name");
else if (ex.Status == WebExceptionStatus.ProtocolError)
{
HttpWebResponse response = (HttpWebResponse)ex.Response;
Console.WriteLine(response.StatusDescription); // "Not Found"
if (response.StatusCode == HttpStatusCode.NotFound)
Console.WriteLine("Not there!");
}
}
}
}