Where does the dispose method lie and how can it be used to
clean up resources?
Answer Posted / rutu
Dispose() is available in System.IDisposable interface.
Microsoft has suggested two methods that can be invoked by
the programmer for the release of resources i.e Close() and
Dispose().
If any of the method is invoked by the programmer before
loosing the reference to an object, care must be taken to
avoid finalze() to be invoked on the same object when it is
garbage collected and we can do this using
GC.SuppressFinalise().
Public Sub Dipose()' or Close()
'write code here to release the resources
GC.SuppressFinalize(Me)
End Sub
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is firstordefault c#?
What is a thread c#?
What is ado net in c#?
Explain polymorphism in c# with a simple example?
In languages without exception-handling facilities, we could send an error-handling procedure as a parameter to each procedure that can detect errors that must be handled. What disadvantages are there to this method?
Can we inherit static class in c#?
Are there functions in c#?
What is state c#?
How do I unload an assembly?
Is void a class?
Which namespace is required to implement trace ?
Is it possible to have a static indexer in c#?
What is the difference between ref & out parameters in c#?
What are the 4 pillars of any object oriented programming language?
Why we use delegates in c#?