I was reading and I am unsure about the difference between the managed and basic resources mentioned in the article.
I have a class whose 2 fields should be disposed of, should I treat them as managed (only to be settled at the time of disposal) or the original resource?
A managed resource is another managed type, which implements IDisposable
. Write to Disposes ()
any other IDisposable
which you use. Native resources are anything beyond the managed world like native Windows handles etc.
Edit : Answer the question in the comment (too long for comment)
No, it's just a managed type The type created from, which does not apply to IDisposable
, will be controlled by the garbage collector and you do not need to do anything else if your type directly uses a native resource (such as Win32 libraries Is called), you will see the IDis on your code Posable and have to implement resources in the
Dispose
method. If your type uses the basic resource explained in any other way, which implements IDisposable
, then you Dispose
in Dispose () on such examples.
will need to call your method
Comments
Post a Comment