가능한 중복 :
Close and Dispose - which to call?Dispose와 Close의 차이점은 무엇입니까?
안녕하세요,
일부 웹 페이지를 읽은 후, 나는 아직도 C#에서 폐기 닫기 방법의 차이를 이해하지 않습니다.은의이 샘플을 보자 :
using (SqlConnection sqlConnection = new SqlConnection())
{
// Execute an insert statement (no breaks, exceptions, returns, etc.)
}
와 두 번째를 :
SqlConnection sqlConnection = new SqlConnection();
// Execute an insert statement (no breaks, exceptions, returns, etc.)
sqlConnection.Close();
코드의 두 조각 비슷한
있습니까? 모두 사용할 상황이 있기 때문에using
는 해결책이 아니다? 아니면 행동에 차이가있을 경우 (단지 편의상 있습니까? 어떤 클래스가
Close
방법을 제공하는 경우가해야하는 이유
그래서 나는
IDisposable
클래스에
Close
방법을 넣어 I .
복제 됨 중복 됨 http://stackoverflow.com/questions/61092/close-and-dispose-which-to-call – chilltemp
감사합니다. 게시하기 전에 검색했지만 찾지 못했습니다. 나는 그 질문을 닫고있다. –