try catch exception when
static void WebClientDemo() { string str = null; using(WebClient wc=new WebClient()) { try { str = wc.DownloadString("http://www.albahari.com/nutshell/"); Console.WriteLine(str); } catch (WebException ex) when (ex.Status == WebExceptionStatus.Timeout) { Console.WriteLine("Timeout"); } } }