In a situation like this:
SqlConnection cn = new SqlConnection(
ConfigurationManager
.ConnectionStrings["AppConnection"]
.ConnectionString
);
using (cn) {...}
Will the using() statement still close the connection even though it wasn't declared in the using() statement?
Similar to this question: SqlConnection with a using clause - calling close on the connection
Except I am wondering about using the actual connection, not a copy of it.
Yes, but you shouldn't do it.
The documentation for
usingsays (all the way at the bottom):