Skip to content
September 15, 2013 / windperson

Compiler Error CS0157

Here is an intesting C# interview question:

What’s the resulting return value of this method?

int TryExceptionHandling()
		throw new Exception();
		return 0;
	catch(Exception ex)
		int ret = 1;
		return ret;
		int ret = 2;
		return ret;

Actually, this code Won’t Be Compiled!
The C# compiler will generate Compiler Error CS0157:
That is, we can not using some sort of “escape mechanism” (return, goto) to quit the finally block statement execution.


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: