Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


what is the difference between finally and dispose methods?

Answers were Sorted based on User's Feedback



what is the difference between finally and dispose methods?..

Answer / monika

The important difference is timing. Finalize is called
after the .NET garbage collector runs. That can take a
while, depending on how frequently you allocate memory and
in what generation the object lives. Dispose() is the
standardized way to free up the unmanaged resources your
object uses well before the finalizer gets a chance to do
so. A Bitmap would be a good example, it takes very few
managed resources but can eat a huge chunk of unmanaged
memory, depending on the size of the bitmap. If you don't
call Dispose on it after you're done using it, your app can
potentially consume large amounts of unused memory for an
extended amount of time.

While Finalize is called automatically, Dispose() isn't.
You must call it explicitly or you can use the V2.0 "using"
statement in VB.NET or C#. Or the "stack allocation"
syntax in C++/CLI. Using "using" is preferred, it ensures
Dispose() is called, even if there's an exception. When
Dispose() runs, you won't need the finalizer anymore so
call GC.SuppressFinalize(). That makes the finalizer
thread running a lot leaner too.

You don't have to implement Dispose() if your class doesn't
consume unmanaged resources. If it has a member that
implements Dispose(), you'll need to implement Dispose()
too so you can call that member's Dispose() method.

Is This Answer Correct ?    53 Yes 2 No

what is the difference between finally and dispose methods?..

Answer / sunil

finally will execute after the try block. It must execute
if there is any exception caught in the catch blobk or not.

Dispose method is the last method executed in the c# program

Is This Answer Correct ?    12 Yes 16 No

what is the difference between finally and dispose methods?..

Answer / m.m.ganesh

compulsory finally will execute after try and catch
block.Dispose method is used to clean up the
objects.Dispose methos will call in finally method to clean
up the objects

Is This Answer Correct ?    6 Yes 19 No

Post New Answer

More C Sharp Interview Questions

What are the Configuration files in .net?

0 Answers  


To catch any possible exception What is the C# syntax written ?

0 Answers   Siebel,


What is or operator in c#?

0 Answers  


code for arranging given number in possible permutation ways ex:123,321,312,132,231,213.

0 Answers  


What is the use of "default" and "Using" keyword?

3 Answers   TCS,


Classes and structs can be declared as static, is this statement true or false?

0 Answers  


What is the interface in c#?

0 Answers  


Explain the Abstract class in c#.net

0 Answers  


Which string method is used for concatenation of two strings in c#?

0 Answers  


What is a service layer c#?

0 Answers  


What is double c#?

0 Answers  


What?s the difference between the System.Array.CopyTo() and System.Array.Clone()?

3 Answers  


Categories