Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

General Rule for When to Implement IDisposable

EDIT: This question is a duplicate of What is the difference between managed and native resources when disposing? (.NET) and many others. Please answer the others if you have something to add.


According to the Framework Design Guidelines by Krzysztof Cwalina and Brad Abrams, a type that contains instances of disposable types should implement IDisposable.

Is there any other general rule of thumb for when it is best practice to implement IDisposable?

like image 634
C-Pound Guru Avatar asked Jul 14 '09 14:07

C-Pound Guru


1 Answers

Implement IDisposable when you have a class what wraps an unmanaged resource or when your class has a field that implements IDisposable.

like image 174
ddc0660 Avatar answered Sep 19 '22 13:09

ddc0660