Arjen,
Your code:
bool noExceptions = true;
try {
// CODE BLOCK 1
}
catch { noExceptions = false; }
if (noExceptions == true) {
// CODE BLOCK 2
}
Could be rewritten as follows:
try {
// CODE BLOCK 1
// CODE BLOCK 2 - happens only if no exceptions in block 1 !!
}
catch {
}
(no variable needed). But then as Nicholas said, instead of "swallowing" the
exception, generally is better to simply write:
// CODE BLOCK 1
// CODE BLOCK 2
(no try-catch at all) and let the calling context to handle the possible
exception.
Regards - Octavio
"Arjen" <bo*****@hotmail.com> escribió en el mensaje
news:dd**********@news5.zwoll1.ov.home.nl...
Hi,
Is there a way to check if there are no exceptions?
I now use the understanding code, are there other options?
bool noExceptions = true;
try { }
catch { noExceptions = false; }
if (noExceptions == true) { }
Thanks!