DisposeAttribute
Description
- Derived from
-
Attribute abstract
Methods attributed with Dispose perform disposal on an object.
There are two situations where this attribute can be used - on an instance method or a static method:
-
Used on instance method (disposing
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.
-
Used on a static method (disposing given parameter value):
[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.