Possible Duplicate:
What is the C# Using block and why should I use it?
Whats the significance of using block? Why should i write my code inside using block?
eg:
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["newConnectionString"].ConnectionString);
using (con)
{
con.Open();
//
// Some code
//
con.Close();
}
Is this the right way of using using statement?
usinggoes together with theIDisposableinterface.It guarantees that before exiting the scope the
Disposemethod would be called on the object in the using clause.There is no other reason than that.