Advertisement
stefanpu

Untitled

Dec 11th, 2012
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.66 KB | None | 0 0
  1.   foreach (var item in urls)
  2.             {
  3.                 try
  4.                 {
  5.                     string html = url.DownloadString(item);//(1)  If exception is thrown here...
  6.                     Console.WriteLine("Start: " + item);//(2) ...this code won`t execute....
  7.  
  8.                 }
  9.                 catch (WebException we)
  10.                 {
  11.                     Console.WriteLine("Invalid uri encountered");//... You can mark catching the exception...                
  12.                 }
  13.                 //(3)... but program will continue from here
  14.                 //(and iterate through the next item of the "foreach" loop, if any are left)
  15.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement