Question: Which lines will be executed if the StreamReader constructor throws an exception? 1 static string ReadFirstLine(string path) 2 { 3 StreamReader file = null; 4

Which lines will be executed if the StreamReader constructor throws an exception?

1 static string ReadFirstLine(string path) 2 { 3 StreamReader file = null; 4 string buffer = null; 5 6 try 7 { 8 file = new StreamReader(path); 9 buffer = file.ReadLine(); 10 } 11 catch (Exception e) 12 { 13 Console.WriteLine("Error reading from {0}. Message = {1}", path, e.Message); 14 } 15 finally 16 { 17 if (file != null) 18 { 19 file.Close(); 20 } 21 } 22 23 return buffer; 24 }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!