Advertisement

09.23.2008 at 04:22AM PDT, ID: 23754464 | Points: 500
[x]
Attachment Details

how to execute finally block in a function when function is of static type and return a value

Asked by psaini172000 in Message Queue

Tags: , , ,

the following error message occus when i run my code
control can not leave the body of a finally clause
code is below

 private static string GetWebText(string url)
        {

try
{
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
            request.UserAgent = "A .NET Web Crawler";
            WebResponse response = request.GetResponse();
            Stream stream = response.GetResponseStream();
            StreamReader reader = new StreamReader(stream);
            string htmlText = reader.ReadToEnd();
            return htmlText;
            //  throw new Exception();
}
finally
{
return htmltext;
}
        }Start Free Trial
[+][-]09.23.2008 at 08:11AM PDT, ID: 22550242

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.23.2008 at 08:16AM PDT, ID: 22550305

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.30.2008 at 08:50PM PDT, ID: 22611492

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628