D
DaTurk
What's the CLI equivalent of the empty catch?
i.e.
try{}
catch
{}
i.e.
try{}
catch
{}
DaTurk said:What's the CLI equivalent of the empty catch?
i.e.
try{}
catch
{}
DaTurk said:What's the CLI equivalent of the empty catch?
i.e.
try{}
catch
{}
SvenC said:Where is that empty catch allowed? It is not standard C++. Do you mean
catch(...) ?
Where is that empty catch allowed? It is not standard C++. Do you mean
catch(...) ?
It's allowed in C#. It's equivalent to the C++/CLI construct:
try
{
}
catch(Exception^)
{
}
DaTurk said:What's the CLI equivalent of the empty catch?
i.e.
try{}
catch
{}
Jochen Kalmbach said:Hi Carl!
No. "catch(Exception^)" is *not* the same as "catch" in C#!
"catch(Exception^)" will *only* catch exceptions which are derived from
"System.Exception"!
"catch" will catch *all* Exceptions (derived from "System.Object")!
It also will catch native exceptins in C#!!!
Wouldn't catch (Exception^) do so as well, giving an SEHException? Or is
that only for p/invoke?
Jochen Kalmbach said:Hi Ben!
SEHException is also derived from "System.Exception". But you can throw
*any* object as an exception. Therefor, if you want to catch *all*
exceptions, you need to catch "System.Object" instead of
"System.Exception"!
See:
I wasn't doubting that catching System.Object will catch all exceptions...
but wouldn't catching System.Exception also catch all exceptions, decoding
managed objects derived from Exception, and wrapping everything else in
SEHException?
I don't understand the background of this question?
I don't know the internals of every assembly; so I don't know if
"System.Exception" will catch *all* exceptions... regardless of
SEHException...