Best practice is to catch a specific exception first and then move on to more general ones.
Exception Handling (C # Programming Guide)
catch . catch , catch . catch, . catch , catch, , . ( ).
:
, "", , .
catch NullReferenceException. NullReferenceException, , null, . , .
string str = null;
try
{
Console.WriteLine(str.Length)
}
catch(NullReferenceException ne)
{
}
.
if(str != null)
Console.WriteLine(str.Length);
EDIT:
, . , , IMO, , , , , , . . ( ) , , , " ", .
(, - ), , .
, ASP.Net Application_Error, .
2:
OP:
, , , SQLException
- , . , , SqlException, .