Is this the 'correct' way to ignore exceptions?
public void Close()
{
try
{
MethodThatMayThrowException();
}
finally
{
FlagClosed = true;
}
No, because "finally" does not swallow the exception. It just ensures
that code inside will run even if exception happens while executing
whatever is inside "try".
To ignore a specific exception, you just use an empty catch block:
try { ... } catch (IOException) {}
Ignoring all exceptions is generally not something you ever want to
do, except when you're developing for SharePoint *sigh*. In which case
you just catch anything derived from Exception.
Of course, even ignoring a very specific exception is something that
raises an eyebrow. Typically, you'd at least have some logic there
depending on whether it happens or not, and not an empty catch,