In C#
, how does a try catch finally block work?
So if there is an exception, I know that it will jump to the catch block and then jump to the finally block.
But what if there is no error, the catch block wont get run, but does the finally block get run then?
Yes, the finally block gets run whether there is an exception or not.
Try [ tryStatements ] [ Exit Try ] [ Catch [ exception [ As type ] ] [ When expression ] [ catchStatements ] [ Exit Try ] ] [ Catch ... ] [ Finally [ finallyStatements ] ] --RUN ALWAYS End Try
See: http://msdn.microsoft.com/en-us/library/fk6t46tz%28v=vs.80%29.aspx