Advertisement
stefanpu

Untitled

Dec 11th, 2012
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.65 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.                 catch (WebException)
  9.                 {
  10.                     Console.WriteLine("Invalid uri encountered");//... You can mark catching the exception...                
  11.                 }
  12.                 //(3)... but program will continue from here
  13.                 //(and iterate through the next item of the "foreach" loop, if any are left)
  14.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement