???????using?????????????
????3.1????????????IDisposeable???????????????????????????????????
?????磺

 

using(stringstrMsg="MyTest")
{
Debug.WriteLine(strMsg);//Can'tbecompiled
}
????3.2???????using???????????????飬?????????????????飬??????????????????????
SqlConnectionsqlConn=newSqlConnection(yourConnectionString);
objectobjConn=sqlConn;
using(objConn)
{
Debug.WriteLine(objConn.ToString());//Can'tbecompiled
}
???????????????????????“as”???????????????????????
SqlConnectionsqlConn=newSqlConnection(yourConnectionString);
objectobjConn=sqlConn;
using(objConnasIDisposable)
{
Debug.WriteLine(objConn.ToString());
}
????3.3???????????????????????????????????????????д??
using(SqlConnectionsqlConn=newSqlConnection(yourConnectionString))
using(SqlCommandsqlComm=newSqlCommand(yourQueryString??sqlConn))
{
sqlConn.Open();//Openconnection
//OperateDBhereusing"sqlConn"
sqlConn.Close();//Closeconnection
}
??
  ??????????????????????д?????
using(FontMyFont=newFont("Arial"??10.0f)??MyFont2=newFont("Arial"??10.0f))
{
//useMyFontandMyFont2
}//compilerwillcallDisposeonMyFontandMyFont2
????3.4??using???????????C#???????VB?????????????ж????????
????PS????C# using?????????????????????????????