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 these statements
obj=null and obj.dispose()

Answers were Sorted based on User's Feedback



What is the difference between these statements obj=null and obj.dispose() ..

Answer / sanjeev

obj=null
when we use obj=null then this object has existence in
memory with no any value.

obj.dispose()
when we use obj.dispose() then the clr release the memory
and there are no any existence of that object into the
memory. so it will be better to use obj.dispose()

Note:- By default it is automatically disposed by the clr
when there are no any references in the left

Is This Answer Correct ?    8 Yes 0 No

What is the difference between these statements obj=null and obj.dispose() ..

Answer / pushparaj pentakota

obj=null is remove the reference to object only but that
object will be existed but obj.dispose() is clear the
reference and as well as clear the object also from the
memory.so obj.dispose() is best to use but in some cases not.

Is This Answer Correct ?    2 Yes 0 No

What is the difference between these statements obj=null and obj.dispose() ..

Answer / dhinaharan

obj.dispose has to be used and not obj=null, bcoz JIT
compiler is optimizing compiler, and setting a local
variable or parameter to null is the same as not
referencing the variable at all.

Is This Answer Correct ?    2 Yes 1 No

What is the difference between these statements obj=null and obj.dispose() ..

Answer / kishoreg

This is not a good and safe practice to call a Dispose.
In "Dot Net" it is automatically handle by Garbage
collection. It is the responsibility of GC to call the
Dispose and clear the memory.. but it is not sure that when
GC will call the Dispose.

so in that case we can forcefuly call it.

Consider one case when we forcefully destroy the object and
after some time i will try to use the same object at that
time u will get the error msg.

so better to object = null;

other material:
http://blogs.msdn.com/irenak/archive/2006/10/05/SYSK-
212_3A00_--Does-.NET-Garbage-Collector-call-Dispose_3F00_--
Dispose-_1320_-Best-Practices_2E00_.aspx

Is This Answer Correct ?    4 Yes 4 No

Post New Answer

More C Sharp Interview Questions

what is virtual method in c#?

0 Answers  


How can I develop an application that automatically updates itself from the web?

0 Answers  


Difference between imperative and interrogative code?

1 Answers   VelTech, Wipro,


can multiple catch blocks be executed for a single try statement?

0 Answers   Siebel Systems,


Is string reference type / value type ?

7 Answers   3i Infotech, Accenture, BirlaSoft,


how background thread access to ui control?

0 Answers   HCL,


How big is a 64 bit integer?

0 Answers  


What are "class access modifiers" in C#?

0 Answers   Genpact,


Explain about ODP.net

0 Answers  


how to stored and retrive video in Sql server using asp.net c#......?

0 Answers   Sans Pareil IT Services,


Why do we use namespace in c#?

0 Answers  


7.What are typed data set?

2 Answers   Ebix, Mphasis,


Categories