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
Both constructs (catch ()
being a syntax error, as sh4nx0r rightfully pointed out) behave the same in C#. The fact that both are allowed is probably something the language inherited from C++ syntax.
Others languages, including C++/CLI, can throw
objects that do not derive from System.Exception
. In these languages, catch
will handle those non-CLS exceptions, but catch (Exception)
won't.