I want to know if I can safely write catch() only to catch all System.Exception types. Or do I\'ve to stick to catch(Exception) to accomplish this. I know for other exceptio
catch(Exception ex)
can handle all exceptions which are derived from System.Exception
class, however if the exception thrown is not derived from System.Exception
then it will not be handled by catch(Exception ex)
.
Prior to .NET 3.0 exceptions thrown by unsafe code (i.e. code not targeting CLR) were handled by catch{}
. After .NET Framework 3.0 all types of exception can be handled by System.Exception
class. catch{}
is now obsolete .