Larry, take the following example... public long Divide( long x) { long i = 0;
try { i = x / i; } finally; { i = 1; } return i; } The way this code is written you are guarenteed to throw an exeption in the try block. If I do, what does the caller see? Does the caller see an exception or does the method return? Based upon my understanding of try/catch/finally, the return statement never gets executed and the caller is thrown an exception. So my point is that a ~really~ smart compiler ~might~ be able to figure that out and adjust its errors (like the one in the original posting) accordingly. The most excellent points made earlier on this thread point out that the compiler error probably saves our collective buts enough times that we can just work with it when its not quite as ~smart~ as I would like it. ;-) Later, curt ----- Original Message ----- From: "Larry McCoy" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, April 19, 2002 3:05 PM Subject: Re: [DOTNET] Use of unassigned local variable Curt, Why do you say you aren't going to execute the return statement? As I read the code, the "return author" statement WILL execute after the finally block completes. The only way I can see that the return statement wouldn't get executed is if you had a catch block, and rethrew the exception (but that does not appear to be what you are doing.) If you do intend to do that, then you probably would want to put the return statement inside of the Try block. HTH Larry -----Original Message----- From: Curtis Koppang [mailto:[EMAIL PROTECTED]] Sent: Friday, April 19, 2002 8:10 AM To: [EMAIL PROTECTED] Subject: Re: [DOTNET] Use of unassigned local variable I guess it's too much to ask for the compiler to figure this out. Here is what I mean. If I get an exception on a line in the try block, the only code I am executing is the code in the finally block. I am not going to execute the return, so why do I care if it has a valid value or not. Later, curt You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com. You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.