Difference between dispose and finallize method?



Difference between dispose and finallize method?..

Answer / Rohit Kandulna

Dispose() is a virtual method that should be implemented by objects to free unmanaged resources they hold, such as file handles or database connections. Dispose() can be called explicitly by the developer at any time. Finalize() is an overridable destructor method in C# that gets called automatically by the garbage collector when the object is about to be destroyed. Its primary purpose is to clean up unmanaged resources that cannot be released through Dispose(). The difference between them lies in when and how they get called: Dispose() can be called at any time, while Finalize() only gets called by the garbage collector during garbage collection.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Dot Net General Interview Questions

What are the differences between user control and server control?

1 Answers  


How many types of generations are there in a garbage collector?

1 Answers  


What is a manifest in .net?

1 Answers  


What is Polymorphism? How does VB.NET/C# achieve polymorphism?

1 Answers  


What is a Manifest?

1 Answers   CTS,


How do you create threading in.net?

1 Answers  


What is the difference between Server.Transfer and Response.Redirect?

4 Answers  


What is the difference between constants and read-only variables?

1 Answers  


What is .net code security?

1 Answers  


Different between .net & j2ee ?

1 Answers  


What are the different types of assemblies?

3 Answers  


What is the lapsed listener problem?

1 Answers  


Categories