The following code won't work, because conn goes out of scope before you enter the catch block.
try
{
Connection conn = new Connection();
conn.Open();
}
catch
{
if (conn != null) conn.Close();
}
Connection conn = null; // Note the assignment to null to avoid error CS0165 - Use of possibly unassigned local variable 'conn'.
try
{
conn = new Connection();
conn.Open();
}
catch
{
if (conn != null) conn.Close();
}