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 exception types (e.g. InvalidCastException), I have to specify the type as catch(InvalidCastException). In other words, I'm asking if the following code samples are the same.
This ...
try
{
//do something
}
catch(Exception)
{
//handle exception
}
this ...
try
{
//do something
}
catch() //Causes compile time error "A class type expected"
{
//handle exception
}
and this ...
try
{
//do something
}
catch
{
//handle exception
}
update: There was an error in my question. catch()
is not allowed in c#.