ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
Google
 
Categories  >>  Software  >>  Microsoft Related  >>  C Sharp
 
 


 

 
 Visual Basic interview questions  Visual Basic Interview Questions
 C Sharp interview questions  C Sharp Interview Questions
 ASP.NET interview questions  ASP.NET Interview Questions
 VB.NET interview questions  VB.NET Interview Questions
 COM+ interview questions  COM+ Interview Questions
 ADO.NET interview questions  ADO.NET Interview Questions
 IIS interview questions  IIS Interview Questions
 MTS interview questions  MTS Interview Questions
 Crystal Reports interview questions  Crystal Reports Interview Questions
 BizTalk interview questions  BizTalk Interview Questions
 Dot Net interview questions  Dot Net Interview Questions
 Exchange Server interview questions  Exchange Server Interview Questions
 SharePoint interview questions  SharePoint Interview Questions
 Microsoft Related AllOther interview questions  Microsoft Related AllOther Interview Questions
Question
What is the difference between these statements 
obj=null and obj.dispose()
 Question Submitted By :: Kiran
I also faced this Question!!     Rank Answer Posted By  
 
  Re: What is the difference between these statements obj=null and obj.dispose()
Answer
# 1
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 ?    3 Yes 3 No
Kishoreg
 
  Re: What is the difference between these statements obj=null and obj.dispose()
Answer
# 2
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 ?    0 Yes 0 No
Dhinaharan
 
 
 

 
 
 
Other C Sharp Interview Questions
 
  Question Asked @ Answers
 
What is covariance and contravariance? Did Delegate and method overriding support these? TCS1
What are the two kinds of properties? Wipro10
Can we have private constructor in our class file. When we are trying to create instance for the class will it create or throw error regarding that?  3
Is array reference type / value type? Accenture11
How you will connect to windows directory in c#? HP2
Can you override private virtual methods?  3
How to make a class non-inheritable other than sealed?  3
What does the keyword virtual mean in the method definition?  2
What are the valid parameter types we can pass in an Indexer ? CMC3
When you inherit a protected class-level variable, who is it available to? Visual-Soft2
How to navigate from one page(form) to another page(form) using C#.net...please give me the example  2
what are the events in delegate? Choice-Solutions2
Where is the output of TextWriterTraceListener redirected?  1
What?s the .NET datatype that allows the retrieval of data by a unique key?  2
Can you inherit multiple interfaces?  2
what are the advantages of c# over vb.net? Choice-Solutions6
What is stack and heap? Wipro4
Difference between dispose and destructor? TCS2
How to throw an caught exception from cath block? TCS3
What does assemblyinfo.cs consists ? Microsoft2
 
For more C Sharp Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com