Methods attributed with Dispose perform disposal on an object.
sealed class
|
Dispose
|
extends
|
Attribute
|
There are two situations where this attribute can be used - on an instance method or a static method:
this
):
[Dispose] void TheMethodNameCanBeChosenFreely();The method will dispose the object it is called on. A class is said to be disposable iff there is such an instance method for disposal.
[Dispose] static void TheMethodNameCanBeChosenFreely(T disposable);The method will dispose the given parameter value. This can be necessary when using 3rd party libraries or complex types that cannot be fitted with an instance method for disposal (see above), thus remaining non-disposable.