if i do just try and finally without any catch if an exception ocurrs it will be ignored or a ExceptionFound message will pop up?
Printable View
if i do just try and finally without any catch if an exception ocurrs it will be ignored or a ExceptionFound message will pop up?
Doing this causes an error because it isn't caught:
Code:try
{
MessageBox.Show("hello");
throw new System.Exception("My exception");
}
finally
{
MessageBox.Show("Here is the finally block");
}
finally is optional.
catch is not.
If you don't want to catch the error, i.e. just ignore it, still put an empty catch:
Code:try
{
//Statement that might generate error
}
catch
{
}