What is the difference between these statements
obj=null and obj.dispose()
Answer Posted / 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 View All Answers
What is the correct way of declaring an xml namespace?
Can a class have multiple constructors c#?
What are the Types of JIT and what is econo-JIT
What is console write in c#?
What is task parallel library?
What is c sharp used for?
What is uint16?
State two different types of access modifiers.
Why do we need abstract class?
What is a void c#?
Why should you override the tostring() method?
If casting fails what type of exception is thrown?
If you define a user defined data type by using the struct keyword, is it a value type or reference type?
How do I do a case-insensitive string comparison?
What is a constructor in c#?